string breakline

i have problem with the break line.

i got a string sentence. not char.

string sentence = "How are u? I am fine."

how can i break the line to:

How are u?
I am fine.
Last edited on
 
string sentence = "How are you?\nI am fine.";
but i problem is that it is a txt file and i have to break the line.

int main()
{
string line, str1, str2, str3;

string wordSearch;

size_t found ;
size_t pos ;

char fileName[MAX_FILE];

cout <<"Enter the filename:";

cin >> fileName;

fflush(stdin);

cout << endl;

ifstream fin;

fin.open (fileName);

if(!fin.good())
{
cerr << "File not found" << endl;

system("pause");

exit(1);
}

cout <<"Word Search:";

cin >> wordSearch;

fflush(stdin);

cout << endl;

while (!fin.eof())
{

getline(fin,line);

for(int i=0; i < line.length(); i++)
line[i] = tolower(line[i]);

for(int i=0; i < wordSearch.length(); i++)
wordSearch[i] = tolower(wordSearch[i]);

found = line.find(wordSearch); // search for cin words
pos = line.find_first_of(".!?", line.length());
.......
Last edited on
Topic archived. No new replies allowed.