?
=?ISO-8859-1?Q?Martin_J=F8rgensen?=
Hi,
Since I'm a newbie I have some small but quick (probably) stupid
questions also
This is my "get_double" function which takes a default argument also of
type double. The function returns a value of type double so I can write
something like value = getdouble(0.5); in my program.
--------------
double get_double(double default)
{
double input;
char ch;
while (scanf("%lf", &input) != 1) /* if valid input was not entered */
{
while ((ch = getchar()) != '\n')
putchar(ch); /* dispose bad input */
printf(" is not valid input. Assuming default value: %lf\n", default);
input = default;
}
return input;
}
--------------
The compiler says:
syntax error : missing ')' before 'default'
syntax error : missing '{' before 'default'
syntax error : 'default'
syntax error : ')'
It probably thinks I'm trying to cast some value to type double I
guess....? What is it complaining about?
It is declared in the beginning as:
double get_double(double); /* get input of type double */
Med venlig hilsen / Best regards
Martin Jørgensen
Since I'm a newbie I have some small but quick (probably) stupid
questions also
This is my "get_double" function which takes a default argument also of
type double. The function returns a value of type double so I can write
something like value = getdouble(0.5); in my program.
--------------
double get_double(double default)
{
double input;
char ch;
while (scanf("%lf", &input) != 1) /* if valid input was not entered */
{
while ((ch = getchar()) != '\n')
putchar(ch); /* dispose bad input */
printf(" is not valid input. Assuming default value: %lf\n", default);
input = default;
}
return input;
}
--------------
The compiler says:
syntax error : missing ')' before 'default'
syntax error : missing '{' before 'default'
syntax error : 'default'
syntax error : ')'
It probably thinks I'm trying to cast some value to type double I
guess....? What is it complaining about?
It is declared in the beginning as:
double get_double(double); /* get input of type double */
Med venlig hilsen / Best regards
Martin Jørgensen