B
broeisi
What advantages does sscanf offer over scanf?
I had the following code:
#include <stdio.h>
#include <string.h>
int main(void)
{
int start, finish, values;
char line[10];
memset(line,0, 10);
printf("Event numbers ? ");
fgets(line, sizeof(line), stdin);
values = sscanf(line,"%d %d", &start, &finish);
printf("start = %d en finish = %d values = %d\n",
start, finish, values);
return 0;
}
but if tha user inputted for example : erte 5 6 ..the output of start
and finished would not be 5 or 6 but some strange value...
I thought that sscanf would find values that are integers and assign
those integer values to the variables?
If not how can I accomplish this?
I had the following code:
#include <stdio.h>
#include <string.h>
int main(void)
{
int start, finish, values;
char line[10];
memset(line,0, 10);
printf("Event numbers ? ");
fgets(line, sizeof(line), stdin);
values = sscanf(line,"%d %d", &start, &finish);
printf("start = %d en finish = %d values = %d\n",
start, finish, values);
return 0;
}
but if tha user inputted for example : erte 5 6 ..the output of start
and finished would not be 5 or 6 but some strange value...
I thought that sscanf would find values that are integers and assign
those integer values to the variables?
If not how can I accomplish this?