getline?

if you are doing something like

ifstream categ("category");

categ.getline(hold,100);
char tex[50];

while(){
strcpy(tex,hold);
}

how do you test when to stop if it hits an enter? Thanks
What do you mean?

The getline() function reads until the end of file / beyond end of line.
It copies the line to the provided buffer (-> hold), but not more than the provided size (-> 100).
The end of line char is not copied, but a 0 char is appended

hence in your case hold must be char hold[101]; // Note: 1 more char

See: http://cplusplus.com/reference/iostream/istream/getline/
Topic archived. No new replies allowed.