0

Hello everyone,

I have a question about the getline() function. I want to read from a text file and add each sentence to a string array, separating them by the full-stop.

The getline() function format for input from a text file is different from the one that takes keyboard input. The keyboard input one allows the use of delimiters to separate the input, but the file input format does not.

char test[100];
  cout << "Input: ";
  cin.getline (name,100,/*delimiter*/);

// as opposed to 

    ifstream i;
    i.open("test.txt");
    string s;
    getline(i,s);
    i.close();

so the question is, is it possible to add the delimiter to the txt file input version as well? if so how?

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by WaltP
0

Well that is embarrassing, i had it completely wrong.:( Still thanks for pointing me in the proper direction.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.