0
The Directives for string
Hey 😊 I tried to exclude #include<string> and just have the iostream as per the little description on the 'Strings' tab, and the program failed to work. When I tried the other way around... that failed as well. What am I doing wrong?
4 Respostas
+ 8
Some compilers automatically include the <string> header for you when you include <iostream>, but there is no guarantee for it to happen. VS compiler, for example, does not. Hence, it is encouraged that you include the <string> header whenever your code involves the use of std::string.
+ 1
Post your code please. It will be easier to answer.
+ 1
Oh, I understand now, thank you. I am, in fact using Visual Studio so that explains it. ☺️
- 1
I'm working on something bigger, but this is what I was testing to find an efficient method:
#include <iostream>
#include <string>
#include <cstdlib>
int Main()
{
std:: string word;
std::course << "Please enter a word\n\n";
std::cin >> word;
system("pause");
return 0;
}