the code below is ment to read the first char of every line of a .txt file
except when it comes accorss grouped returns it has a habbit of skipping a line iv'e been sitting on this for almost 2-3 hours and im banging my head against the wall with it...
I tryed to catch it with an if statement but it's not quite working.
Heres the code thats troubleing me:
Code:
char reader; //Reads the file
FILE *obj = NULL;
obj = fopen("test1.obj", "r"); //Open File
if(obj == NULL) //Error Check
{cout << "file not opened!";}
else
{cout<< "opened file! :)" << endl;}
reader = getc(obj);
cout << reader << endl;
for (int x = 0; x < 10; x++) // get 10 lines of info
{
do //find the next line value
{
reader = getc(obj);
}while(reader != '\n');
reader = getc(obj); //goto next byte
if(reader == '\n')
{
cout << "\n";
}
else
{
cout << reader << endl;
}