Hi -
I'm trying to seperate out some numbers from a large text file and place those numbers in a formated fashion inside another text file. I'm working in MS Visual C++. The file i'm reading from has lines line the following:

AT BUS [CALN HHG000 138.00] 77904 AREA 7 (KV L-G) V+: / 0.000/ 0.00 (KV L-G) VA: / 0.000/ 0.00 V0: / 42.250/ 178.86
THEV. R, X, X/R: POSITIVE 0.03296 0.13488 4.093 NEGATIVE 0.03297 0.13493 4.092 ZERO 0.08720 0.30104 3.452

I need the 77904 from the first line and the first two numbers after "POSITIVE" and "ZERO" on the second line. This format of text is always the same because a computer program generates a large .txt file with all these numbers in it and rather than sort through it and copy the numbers by hand, i'd rather write a text file that grabs those fields i need and shoves them into a txt file seperated by commas or tabs so that i can easily import them into Excel. Here's my code:

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main(int argc, char* argv[]){
char* inFile;
char* outFile;
string line;
int firstMarkPos = 0;
int secondMarkPos = 0;
char busNum[] = "";

/**/ char firstMarker[] = "]"; /**/
/**/ char secondMarker[] = "AREA"; /**/

if(argc < 3){//Check argc. If too few arguments inform user of syntax.
cout << "Syntax: text_parser.exe <readFile> <writeFile>" << endl;
return 1;
}else{//if you got enough parameters

cout << argv[0] << endl;//for debug purposes. Remove later.

//inFile and outFile point to the beginning of the char array that contains
//the user's commands
inFile = argv[1];
outFile = argv[2];

//open the file the user specifies and copy the text from the input file...
ifstream inputF;
ofstream outputF;

getline(inputF,line);//grab a line from the text file
firstMarkPos = line.find(firstMarker);
secondMarkPos = line.find(secondMarker);

if(firstMarkPos != string::npos && secondMarkPos != string::npos){//If both markers are detected...

//copy the string inbetween the markers to the character array, busNum...
line.copy(busNum,secondMarkPos - (firstMarkPos + 1),firstMarkPos + 1);

for(int i = 0; i <= strlen(busNum);i++){
if(busNum[i] == ' '){
//do nothing
outputF << busNum[i];//possibly wrong

outputF << "\n";

//only one marker or no markers detected
//cout << firstMarker << " " << firstMarkPos << endl;
//cout << secondMarker << " " << secondMarkPos << endl;
//cout << line << endl;//to the screen...
//outputF << line << endl;//and to the file!

outputF.close();//close both files

system("pause");//allow user to see that the program is complete before exiting

return 0;

Thanks for your help!