See this main
:
int main(void)
{
int i;
int ch;
char str[512];
fgets(str, sizeof str, stdin);
for (i = 0; i <= (strlen(str)); i++)
{
if (str[i] != '\0' && str[i] != '\n')
{
int num = atoi(&str[i]);
printf("%d\n", num);
}
}
return 0;
}
I want to get line with numbers from user and get all the numbers without any spaces
or tabs
.
For example:
The input 1 2 3
.
But in this case this the output:
1
2
2
3
3
So why i received 2
and 3
twice?