Advertisement

Polygonal String Processing

Started by April 29, 2001 06:13 PM
3 comments, last by Zy 23 years, 9 months ago
I''m using C++ to do some data reading from a standard ASCII text file. Here is an example text file: ------------------------------- 3 100,200 300,400 500,600 4 111,222 111,333 111,444 111,555 2 222,111 333,888 ------------------------------- Notice how the first number of each row tells you how many pairs of numbers follow it. Here is my problem, I can''t think up of a quick way to extract these pairs of numbers. Normally I use sscanf to read the values, but with sscanf you have to know exactly how many values to read in. Does anyone know of a way to read in the first number and then use some sort of loop the read in the pairs of numbers? You probably can tell that I''m new to this. In case you are wondering those numbers correspond to number of polygon vertices, followed by their vertex number and texture vertex number.
  /*   To Read One Line:     Assume FileIn is a FILE * that is already open*/int count;int a, b;fscanf(FileIn,"%d",&count);for(int d=0; d<count; d++) {  fscanf(FileIn,"%d%*c%d",&a,&b);  /* Store a and b somewhere permanent */}  



Resist Windows XP''s Invasive Production Activation Technology!
http://druidgames.cjb.net/
Advertisement
That looks simple. Thanks.

So fscanf doesn''t automatically read the next line everytime it is executed.

One more question what does "%d%*c%d" mean. I know %d is the integer, but what is "%*c"?


Any character I think, for the comma''s
It means discard a single character.

Resist Windows XP''s Invasive Production Activation Technology!
http://druidgames.cjb.net/

This topic is closed to new replies.

Advertisement