try this :

Code: c++
#include <iostream>
#include <string>
#include <fstream>
using namespace std;


int main(int argc, char* argv[])
{
    string inputstring;
string line;
ifstream myfile ("C:\\W04In.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);

string inputstring (line);

string FirstName,MiddleInitial,LastName,StudentID;
size_t start, end;
start = 0; //initial start value

for (int counter=0;counter<4;counter++)
{
end=inputstring.find_first_of(",", start);
switch(counter)
{
case(0): FirstName=inputstring.substr(start,end);
break;
case(1): MiddleInitial=inputstring.substr(start,end-start);
break;
case(2): LastName=inputstring.substr(start,end-start);
break;
default: StudentID=inputstring.substr(start,end-start);
}
start=end+1;
}
string NewStudentID=StudentID.substr(2,3);
cout << LastName << ", " << FirstName<< ", "<< FirstName <<LastName<<StudentID<<"@student.college.net\n\n ";
cout << LastName << ", " << FirstName<< ", "<< FirstName <<LastName<<NewStudentID<<"@student.college.net\n\n ";
//pare down StudentID to the last three numbers
//concatonate strings to make email address
//output to file
}

//myfile.close();
}

else cout << "Unable to open file";

system ("pause");
return 0;
}

and please share the output...

Last edited by poornaMoksha; 13Sep2011 at 14:09..