Faux 0 Newbie Poster

I need help making two substrings(I think) to get the integer values (course hours, grade) for each course. I thought I had it but every time I ran the .exe it would crash after obtaining the name and major, so I deleted that code altogether. It'd be grand if someone can point me in the right direction here.

.........................................................................
Text file reads:

Name:John Q. Student
Major:Basket Weaving

Stitching 102: 3 4
Cross Weaving 244: 3 3
Basket Fibers 287: 3 2
Basket Shapes 155: 3 3

........................................................................

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
ifstream inFile;
ifstream outFile;
string input;
string output;

cout << "Please enter in the name of the input file: ";
cin >> input;
inFile.open(input.c_str());
cout << input << endl;
if(!inFile)
{
cout << string(15,'*') << " File Open Error "
<< string(15,'*') << endl;
cout << "==> Input file failed to open properly!!\n";
cout << "==> Attempted to open file: " << input << endl;
cout << "==> Terminating program!!!\n";
cout << string(46,'*') << endl;
return 1;
}

cout << "Please enter in the name of the output file: ";
cin >> output;
outFile.open(output.c_str());;
cout << output << endl;
if(!outFile)
{
cout << string(15,'*') << " File Open Error "
<< string(15,'*') << endl;
cout << "==> Input file failed to open properly!!\n";
cout << "==> Attempted to open file: " << output << endl;
cout << "==> Terminating program!!!\n";
cout << string(46,'*') << endl;
return 1;
} 

string name; 
string sub; 
size_t pos; 
getline(inFile,name);
pos = name.find(":");
sub = name.substr(pos+1);
cout << sub << endl;

string major;
string sub2;
size_t pos2;
getline(inFile,major);
pos2 = major.find(":");
sub2 = major.substr(pos2 +1);
cout << sub2 << endl;



system("PAUSE");
return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.