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?

Recommended Answers

All 3 Replies

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

Anytime :icon_twisted:

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.