Reputation: 11
I have problem with string reading. From Hell13 World
i need to get the number 13.
while (*znak){
if (isdigit(*znak)){
x=*znak - '0';
printf("%d\n", x);
}
*dst++ = * znak;
znak ++;
}
with my solution, i get number 1 and number 3 separately.
Upvotes: 0
Views: 61
Reputation: 25286
You only get the first digit and then print it. After seeing a digit you must loop until you see no more digits.
if (isdigit(*znak)){
while (*znak && isdigit(*znak))
x= x*10 + *znak++ - '0';
printf("%d\n", x);
}
Upvotes: 1