ok so im scanning this text file for the string "model=" the problem is, i need to pull the numbers after that string until it reached the end of that line, this is an easy script but for some reason its just not happening. If someone smarter than myself could tell me where the script went wrong that would be awesome. Please don't send me a script completely different, I need it in this format to work with my project. Thanks!
Here is my code
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
ifstream openfile;
//input file
openfile.open("modelset.txt");
//input file
char bigarray[300];
//array that takes value of the whole line being scanned
char thearray[300];
//array that takes value of big array until =="model=" or '\n'
char str;
//character (used in thearray to go through each value of bigarray
ofstream File;
//output file (is created)
File.open("testmodel.txt");
//output file (is created)
while(!openfile.eof())
//while input isnt at the end of the file
{
openfile.getline(bigarray,300);
//set the current line values to bigarray
int i=0;
//used to go through thearray one spot at a time
while (str !='\n' && thearray!="model=")
//set all values of thearray to bigarray until its end of line or "model="
{
thearray[i] = bigarray[i];
i++;
}
i=0;
//set i back to 0 so thearray starts at thearray[0]
if (thearray=="model=")
//see if its =="model="
{
delete [] thearray;
//clear all values of thearray (is this right?)
int testarray=1;
//boolean used so I don't effect the value of thearray
while ( testarray==1 )
//while my boolean is true (redundant but important)
{
openfile.get(str);
//start scanning thearray again (this starts after model=)
thearray[i] = str;
i++;
if (str=='\n');
//set my boolean false if its end of line
{
testarray = 0;
}
}
File << thearray << "\n";
//print thearray (the numbers after "model=") into my output file "File" (testmodel.txt)
}
}
}
Yes i know, terrible commenting but i couldnt cmment to the right of ecah line, you get the idea. The comments are under the line that they refer to.
I've attached modelset.txt if you want to see (no i cant edit this file)
The actual modelset.txt is 5.3meg so i just sent this as an example