Advertisement

OT: fscanf

Started by January 18, 2003 06:27 PM
1 comment, last by penetrator 22 years, 1 month ago
fscanf( stream2, "%24c", max_elev); The above instruction reads 24 chars into max_elev. How can i specify a variable number of chars to be read ? Something like int numberofchars=24; fscanf(........ ?????
www.web-discovery.net

Try the following:

int size = 24;
char sz[256];
sprintf(sz, "%%dc", size);
fscanf(stream2, sz, max_elev);

That might work, tho I can''t besure.
------------------------"If it says it loves me, how can it be a virus?"
Advertisement
why not just do like
char line[24];

fgets(line, 24, stream2);

This topic is closed to new replies.

Advertisement