Whenever I type std::getline in Visual Studio, getline gets a red underline and the program will not run. The same code works for a friend using another C++ editor. Here is the program:
#include
int main() {
std::string name;
std::cout < 15) {
std::cout << "Your name can't be over 15 characters";
} else {
std::cout << "Welcome " << name;
}
return 0;
}
Is there something I need to configure in Visual Studio, or is there another way to read a full line of text?
1 Answer
You can keep writing std::cout, std::cin, std::string, and std::getline exactly as you have them. Adding using namespace std; would shorten the code, but it is generally better for beginners to keep the std:: prefix because it makes it clear where those names come from and avoids name conflicts.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically