I have a string that has ints and I'm trying to get all the ints into another array. When sscanf
fails to find an int
I want the loop to stop. So, I did the following:
int i;
int getout = 0;
for (i = 0; i < bsize && !getout; i++) {
if (!sscanf(startbuffer, "%d", &startarray[i])) {
getout = 1;
}
}
//startbuffer is a string, startarray is an int array.
This results in having all the elements of startarray
to be the first char in startbuffer
.
sscanf
works fine but it doesn't move onto the next int it just stays at the first position.
Any idea what's wrong? Thanks.