Using .getline with string instead of char

So, I have a code that is read from a text document and saves it in char bunz . I know this sounds like a dumb question, but I prefer to use string instead of char. Will .getline accept a string if used with ifstream ? Or will I be forced to convert char to string afterwords?

Thanks.

 ifstream filler("C:\\bunz.txt"); char bunz[30+1]; filler.getline(bunz, 40); cout<<bunz; filler.close(); 
+4
source share
1 answer

Notorious for posting answers as comments, Chris Spot. When you use std::getline() , you will never return:

 ifstream filler("C:\\bunz.txt"); string bunz; getline(filler, bunz); cout<<bunz; filler.close(); 
+6
source

All Articles