Ron
September 21st, 1999, 09:04 AM
I have used #include<string.h> and then declared String str1, str2; and have not been able to use cin>>str1; after prompting for input.
|
Click to See Complete Forum and Search --> : string.h Ron September 21st, 1999, 09:04 AM I have used #include<string.h> and then declared String str1, str2; and have not been able to use cin>>str1; after prompting for input. September 21st, 1999, 09:49 AM try using the function: getline (cin, stringname,'\n'); to see what happen. dh mtighe September 21st, 1999, 02:35 PM use it without capitals. #include <string.h> string strFile; mtighe, mtighe@pobox.com ALM September 21st, 1999, 03:41 PM You have 3 problems: 1. The header file is included as <string> (instead of <string.h>) 2. The class you need is string (not String). 3. To use the string class directly, you need to declare the std namespace at the top of the file: using namespace std; Cheers! Alvaro James Curran September 23rd, 1999, 01:46 PM In reply to: 3. To use the string class directly, you need to declare the std namespace at the top of the file: using namespace std; If you're just using one (or even just a few) things from the standard library, it's it's better to insert the individually into the global namespace, instead of dragging the entire library in: using std::string; using std::cin; string Str1, Str2; cin >> Str1; Sometimes, it's best just to qualify the name where it's used: std::string Str1, Str2; std::cin >> Str1; Truth, James codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |