This is my little piece of code. I'm a little rusty, so I don't remember
how to do this 100%. But basically, the below example will allow to
enter a string up to 100 chars, output it and just for kicks, turn it into
a string class object.
It works, but it can be improved on.
Now, my question is this, would there be a way that would liberate me
from the C character array?
I tried this example (all the way at the bottom) in my VC++ 2010 andCode:#include <iostream>#include <ios> #include <limits> using namespace std; int main(int argc, char * argv[]) { char testString[100]; std::cout << "Please enter a string: "; std::cin.getline(testString, 100); cout << "This is the string that you entered: " << testString << std::endl << std::endl; std::string simpleString(testString); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); std::cin.get(); return 0; }
when I typed in getline, my IDE told me the following:
:-/Error: no instance of 'getline' matches the argument list



1Likes
LinkBack URL
About LinkBacks




