/* File: input3.cpp Testing file I/O using >> with strings. */ #include #include #include // so you can use atof() #include // so you can use ifstream using namespace std ; int main() { string str1, str2, str3 ; string str4 ; ifstream ifile("data2") ; // open file for reading getline(ifile, str1) ; // use ifile instead of cin ifile >> str2 ; // use ifile instead of cin cout << "str1 = '" << str1 << "'\n" ; cout << "str2 = '" << str2 << "'\n" ; ifile.close() ; }