Reading vertices and triangles from a file.

Started by
11 comments, last by Grain 19 years, 11 months ago
well since I''m the master of ugly hacks...
make a char dummy =)

char dum;
file >> dum >> dum >> x; // ''X'', '':'', -20.500000

Of course, if this was fscanf you''d write fscanf("X:%f", &x); =)
and boost has a boost::format to make it possible to write like you do in scanf/printf but using the C++ iostream library. Or maybe the boost::tokenizer is more your taste?

Good luck!

}-- Programmer/Gamer/Dreamer --{
I didn''t choose to code, coding choose me.
[ ThumbView: Adds thumbnail support for DDS, PCX, TGA and 16 other imagetypes for Windows XP Explorer. ] [ Chocolate peanuts: Brazilian recipe for home made chocolate covered peanuts. Pure coding pleasure. ]
Advertisement
I solved it on my own.
do{ch=file.get();}while(ch!=':');file >> x; do{ch=file.get();}while(ch!=':');file >> y; do{ch=file.get();}while(ch!=':');file >> z;

My hack is even uglier I think.


[edited by - Grain on May 19, 2004 1:20:55 AM]
Is there a reason you can''t just put a space between the colon and the number in your file? o_O

This topic is closed to new replies.

Advertisement