+ 1
program not print the word after space please guide me
program not print the word after space please guide me #include<iostream> using namespace std; int main(void){ char a[10]; cout<<"enter Name"; cin>>a; int i=0; cout<<a; return 0; }
3 Antworten
+ 12
If you mean after a space that the user enters as input you will want to use std::getline()
Since getline works with strings, you may also need to use a string instead of a char array.
See: http://www.cplusplus.com/reference/string/string/getline/
Like so:
#include<iostream>
#include <string>
using namespace std;
int main(void){
//char a[10];
string a;
cout<<"enter Name";
getline(cin,a);
// cin>>a;
int i=0;
cout<<a;
return 0;
}
+ 3
Umar Farooq Anwar
Do no foget to press the ✅ next to the answer that soved the question.
+ 1
thanku Jay and Ina