// basic file operations
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main ()
{
char* pch;
string line;
fstream myfile;
myfile.open ("Ahoo.txt");
if (myfile.is_open())
{
while (!myfile.eof())
{
getline (myfile,line);
cout<<line<<endl;
pch = strtok (line," ,.-");
while (pch != NULL)
{
cout<<pch;
pch = strtok (NULL, " ,.-");
}
}
myfile.close();
}
else
{
cout<<"File not opened";
}
return 0;
}
I want to create program that read text from a file, copies it to a string and then break it into tokens. This is my first post kindly help!