|
-
September 21st, 1999, 09:04 AM
#1
string.h
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
#2
Re: string.h
try using the function: getline (cin, stringname,'\n'); to see what happen.
dh
-
September 21st, 1999, 02:35 PM
#3
Re: string.h
use it without capitals.
#include <string.h>
string strFile;
mtighe,
[email protected]
-
September 21st, 1999, 03:41 PM
#4
Re: string.h
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
-
September 23rd, 1999, 01:46 PM
#5
Re: string.h
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|