Have another problem with an OBJ model format converter I'm making. As a test, I want to read in data from an OBJ file, and write it out in a different format, and then the other way around.
The problem I currently have is that I want it to be able to recognise comment files and write them without any modification. I am using istream to open the file and read the lines, but I need a way of testing whether or not the line starts with a #.
Also, I need help with reading it into a string.

Bits and pieces of my code so far:
A line with vertices (ie. "v 0.165906 -0.073740 0.414549") will have the v and the first space removed (by removing the first 2 chars), and split at the spaces, with the following code:

Vert_Out SplitVerts(string data, int id)
     //variable defs
     string in_data = data;
     string middle_data = "";
     string array_data[3];
     double out_data [3];
     //remove 'v' and space
     middle_data = in_data.erase(0, 2);
     //split data
     stringstream split(middle_data);
     string token;
     //i for loop
     int i = 0;
     //feed split into array
                         array_data[i] = token;
     //use struct for output vertex
     Vert_Out vert;
     //vert order num, [x-val, y-val, z-val] [from array]
     vert.id = id;
     vert.x = array_data[0];
     vert.y = array_data[1];
     vert.z = array_data[2];
     //return vert for use
     return vert;

The data is stored in the following struct:

struct Vert_Out
       //Vert order number, x-val, y-val, z-val
       int id;
       string x;
       string y;
       string z;

This is the code I have for reading the lines (I WANT THE "line" VARIABLE TO BE A STRING, NOT A CHAR ARRAY!!!)

//open infile
    ifstream infile;
    //open outfile
    ifstream outfile;
    //read line
    char line[35];
    outfile.getline(line, 35);

Now I just need to get the read line into a string, and check the first letter.

Thanks for your time :)

This question has already been answered. Start a new discussion instead.