Category : cin

I’ve encountered a problem with getline(). I’ve googled it and checked multiple pages, but those answers aren’t meant for newbies like me. Here’s the code: #include <iostream> #include <string.h> using namespace std; int main(){ string n,s,a,ad,e; cout<<"Your name: "<<endl; cin>>n; cout<<"Hello, "<<n<<endl; cout<<"Your surname: "<<endl; cin>>s; cout<<"Your age: "<<endl; cin>>a; cout<<"Your address: "<<endl; getline(cin,ad); cout<<"Your ..

Read more

when i use the code below, char command; cin >> command; i want to get only (‘a’,’c’,’d’) as inputs. In other alphabet(int) cases, i can solve the problem using ‘switch statement’ But when someone types multiple characters, my program doesn’t know what is the problem. Just, take one charcter of multiple characters. In conclusion, I ..

Read more