473,405 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

does not take number parameters

This piece of code compiles fine . . .

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include<stdlib.h>
  3. #include <string.h>
  4. #include "getopt.h"
  5.  
  6. int main(int argc, char* argv[])
  7. {
  8.  
  9.     extern char *optarg;
  10.     extern int optind;
  11.     char c;
  12.  
  13.     float number=  12.67; //default value
  14.     float number2= 13.00;
  15.     char name[256]="no_name";
  16.     char optf[256]="";
  17.     while( (c=getopt(argc, argv,"n:o:s:")) !=-1)
  18. {
  19.     switch (c)
  20.     {
  21.         case 'n':
  22.         strncpy(optf,optarg,256);
  23.         number=strtod(optf,NULL);
  24.         break;
  25.  
  26.         case 'o':
  27.         strncpy(optf,optarg,256);
  28.         number2=strtod(optf,NULL);
  29.         break;
  30.  
  31.         case 's':
  32.         strncpy(name,optarg,256);
  33.         //name=
  34.         break;
  35.     }
  36.  
  37. }
  38.  
  39.     printf("this is a number %e and this %e\n",number,number2);
  40.     printf("%s\n",name);
  41. return (0);    
  42.  
  43. }
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?


Expand|Select|Wrap|Line Numbers
  1. //more code here
  2. int main (int argc, char* argv[])
  3.  
  4.     {
  5.  
  6.         extern char *optarg;
  7.         extern int optind;
  8.         char c;
  9.         char optf[256]="";
  10.         double Cu=0;
  11.  
  12.  
  13.  
  14.         while( (c=getopt(argc, argv,"a:")) !=-1)
  15.         {
  16.             switch (c)
  17.             {
  18.                 case 'a':
  19.                 strncpy(optf,optarg,256);
  20.                 Cu=strtod(optf,NULL);
  21.                 printf("activity = %e",Cu);
  22.                 break;
  23.  
  24.             }
  25.  
  26.         }
  27. //more code here
  28.  
Apr 10 '07 #1
1 1611
sicarie
4,677 Expert Mod 4TB
Did you include the getopt.h in the second? Check the types, etc...?
Nov 2 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

44
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);
11
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.
0
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...
3
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
10
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...
14
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does K = parseInt('09') set K to 0? ----------------------------------------------------------------------- ...
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...
92
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);
9
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.