is there some include file that you enter and how do you use it with declaration and cin?
How do you use strings in C++ without using the char* declaration?
Use STL string class. Most C++ compilers now include STL, so you could do
#include %26lt;string%26gt;
....
int main() {
string s;
cout %26lt;%26lt; "enter text:" %26lt;%26lt; endl;
cin %26gt;%26gt; s;
if (!s.empty()) {
cout %26lt;%26lt; "string length = " %26lt;%26lt; s.length() %26lt;%26lt; endl;
}
}
snow of june
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment