How do I fscanf
this piece of data? There are no empty rows between the data and delimeter is a \':\'
VS1234567890654327:Rob Fordfi
You can include the delimiters as part of your format to fscanf
, like this:
while (4 == fscanf(filename, "%[^:]:%[^:]:%d:%d", string[size], name[size], &number1[size], &number2[size])) {
...
}
Note the use of %[^:]
format specifier. It says "any character except ':'
is accepted". Also note that char*
parameters are passed with no ampersand, because they are already pointers.
Demo on ideone.