Fabio A. Mazzarino
Fabio A. Mazzarino

Reputation: 103

fscanf with string and long

I'm trying to parse a file that another function has written with this fprintf:

fprintf(file, "DS;%s;%ld;%ld;%u\n", ds->name, ds->start, ds->period, ds->size)

I'm using this fscanf:

fscanf(file, "DS;%[^;$]s;%ld;%ld;%u", file_name, &file_start, &file_period, &file_size)

file_name is read with no problems. but file_start, file_period and file_size are always 0, even if not expected.

For exemple, the string:

DS;failures;1363978800;600;144

Is parsed like this:

What am I doing wrong?

Upvotes: 3

Views: 259

Answers (1)

MOHAMED
MOHAMED

Reputation: 43518

replace the string format "%[^;$]s" by this %[^;$] ==> remove the s because [] replace the s so no need any more for s

Upvotes: 3

Related Questions