Why doesn't
string x;
std::getline(cin, x)
Do anything? It basically just jumps this line without doing anything at all. I don't understand why, is this outdated or something?
C++ std:getline.....
C++ std:getline.....
The whole "system" is a number of people creating a code all together, this code loops and is there for a "system".
System Zero could also be confirmed with one word "Hacker's"
System Zero could also be confirmed with one word "Hacker's"
-
- Forum Admin
- Posts: 496
- Joined: Sat May 28, 2011 9:14 am
- Location: Germany
This here works for me:
Code: Select all
#include <iostream>
using std::cin;
using std::string;
int main()
{
string x;
std::getline(cin, x);
std::cout << "You entered: " << x << std::endl;
return 0;
}
Basically im making a school project for the end term, and i figured ill make a program which does what you tell it to do. So i started exeprimenting with some raw code to see if i could get to the point i wanted. This for i got stuck in the main function since following code does not work for me!!AMindForeverVoyaging wrote:This here works for me:
Code: Select all
#include <iostream> using std::cin; using std::string; int main() { string x; std::getline(cin, x); std::cout << "You entered: " << x << std::endl; return 0; }
Code: Select all
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
std::string name;
string b;
int x;
cout << "Welcome please enter the password code." << endl;
cin >> x;
if(x==7777){
system("pause");
cout << "What is your name?" << endl;
cin >> b;
cout << "Hello " << b << " what do you want to do today?" << endl;
std::getline(cin, name);
std::cout << name << endl;
system("pause");
}
else{
cout << "Wrong Code" << endl << "press enter to close to application" << endl;
system("pause");
}
return 0;
}
thanks for help.
The whole "system" is a number of people creating a code all together, this code loops and is there for a "system".
System Zero could also be confirmed with one word "Hacker's"
System Zero could also be confirmed with one word "Hacker's"