This piece of code compiles fine . . . - #include <stdio.h>
-
#include<stdlib.h>
-
#include <string.h>
-
#include "getopt.h"
-
-
int main(int argc, char* argv[])
-
{
-
-
extern char *optarg;
-
extern int optind;
-
char c;
-
-
float number= 12.67; //default value
-
float number2= 13.00;
-
char name[256]="no_name";
-
char optf[256]="";
-
while( (c=getopt(argc, argv,"n:o:s:")) !=-1)
-
{
-
switch (c)
-
{
-
case 'n':
-
strncpy(optf,optarg,256);
-
number=strtod(optf,NULL);
-
break;
-
-
case 'o':
-
strncpy(optf,optarg,256);
-
number2=strtod(optf,NULL);
-
break;
-
-
case 's':
-
strncpy(name,optarg,256);
-
//name=
-
break;
-
}
-
-
}
-
-
printf("this is a number %e and this %e\n",number,number2);
-
printf("%s\n",name);
-
return (0);
-
-
}
but when I try to use that in a larger program (below) I get the error message getopt function does not take three parameters. But it does take three parameters. It takes three in the example above and that compiled fine. Can anyone help? -
//more code here
-
int main (int argc, char* argv[])
-
-
{
-
-
extern char *optarg;
-
extern int optind;
-
char c;
-
char optf[256]="";
-
double Cu=0;
-
-
-
-
while( (c=getopt(argc, argv,"a:")) !=-1)
-
{
-
switch (c)
-
{
-
case 'a':
-
strncpy(optf,optarg,256);
-
Cu=strtod(optf,NULL);
-
printf("activity = %e",Cu);
-
break;
-
-
}
-
-
}
-
//more code here
-
1 1611
Did you include the getopt.h in the second? Check the types, etc...?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bamber |
last post by:
Why does f get returned ? (compiled with gcc).
#include<stdio.h>
int func(int a);
main()
{ int f;
f=func(7);
printf("f=%d",f);
|
by: Leroy |
last post by:
Hello,
I have a question regarding the maximum number of parameters that can be
passed to a procedure.
In VB 6 the max was 60.
What is the max for Dot Net?
please and thanks.
|
by: Richard Gregory |
last post by:
Hi,
I have the wsdl below, for an Axis web service, and when I select Add Web
Refernce in Visual Studio the proxy is missing a class representing the
returnedElementsType (see reference.cs below...
|
by: bennett.matthew |
last post by:
Hello,
Is there a good way to make PreparedStatements with a variable number
of parameters?
My queries look something like this:
SET @rowid := null;
SELECT * FROM (
SELECT
|
by: CJM |
last post by:
I'm trying to call a package/procedure in oracle (from an ASP page) which
requires a number of parameters. I have got this working using OO40 but
unfortunately the transaction rollback function...
|
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - Why does K = parseInt('09') set K to 0?
-----------------------------------------------------------------------
...
|
by: Jacn |
last post by:
Hi! I have a several problem with the oracle connection and ADO, I use a executenonquery for a select sentence and I use two output parameters and two input parameters, when I run the application an...
|
by: Heinrich Pumpernickel |
last post by:
what does this warning mean ?
#include <stdio.h>
int main()
{
long l = 100;
printf("l is %li\n", l * 10L);
|
by: bill |
last post by:
Dim Con = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;" &
"data source=c:\_Archive\Documentation - Projects\Hardware Tracking -
2008\IT_Assets.mdb")
Dim dataAdapter As...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |