Hi guys,
I'm having trouble figuring out how to convert a string with new lines into an array of ints.
Simply put, it would convert something like this:
this is a pseudocode of what id like:
I'm having trouble figuring out how to convert a string with new lines into an array of ints.
Simply put, it would convert something like this:
Rich (BB code):
input:
char *s = "32\n\1\n\35\6\n2\n";
output
int i[];
i[0] = 32
i[1] = 1
i[2] = 35
i[3] = 6
i[4] = 2
Rich (BB code):
Parse(char input[100]) {
char *c = input;
int i = 0;
char output[100]
while (c != '\0') { //does this count as one or two chars?
if (c != '\n') {
//put number into output array indexed at i, my problem here is that numbers can have 1-4 digits
i++;
}
c++
}
}