I\'m trying to read the content of a string, inside a multidimensional array...the problem is, when I do this, the sscanf continues reading only the first character only...<
Use the %n
specifier in the format string.
E.g.
#include <stdio.h>
int main(void){
const char *str="A1+A2+A3+A4.";
char col;
int line;
int offset = 0, readCharCount;
while(sscanf(str + offset, "%c%d%*c%n", &col, &line, &readCharCount)==2){
printf("%c, %d\n", col, line);
offset += readCharCount;
}
return 0;
}
/* result
A, 1
A, 2
A, 3
A, 4
*/