A
alternativa
Hi,
I have problem with the following function - it was intended to ask a
user for a 4-digits number:
double ask_for_number (void)
{
char *notint;
char s2[3];
double entered_number;
do
{
printf("\tplease enter 4-digits number: ");
scanf("%s", s2);
if ( strlen (s2) !=4 )
printf ("Wrong input - input must consist of 4 integer
numbers.\n");
else
entered_numberr = strtod(s2, ¬int);
}
while (*notint);
printf ("you entered: %d", entered_number); /* ???? */
return entered_number;
};
My question is: why in the line /* ???? */ we got something else that
input number? I'd like to use entered_number in the other piece of
program, so I have to be sure it works properly... I guess this is a
matter of a strod function - could you give me a clue how it works or
how to write some similar function without strod?
best regards,
a.
I have problem with the following function - it was intended to ask a
user for a 4-digits number:
double ask_for_number (void)
{
char *notint;
char s2[3];
double entered_number;
do
{
printf("\tplease enter 4-digits number: ");
scanf("%s", s2);
if ( strlen (s2) !=4 )
printf ("Wrong input - input must consist of 4 integer
numbers.\n");
else
entered_numberr = strtod(s2, ¬int);
}
while (*notint);
printf ("you entered: %d", entered_number); /* ???? */
return entered_number;
};
My question is: why in the line /* ???? */ we got something else that
input number? I'd like to use entered_number in the other piece of
program, so I have to be sure it works properly... I guess this is a
matter of a strod function - could you give me a clue how it works or
how to write some similar function without strod?
best regards,
a.