How to Do Enter For Space in array of char in c++? -
my code here:
char s[50]; cin.get(s,50); (int = 0; < 50; i++) { if (s[i] = ' ') { //suppose enter } } cout << s << endl;
input:
welcome c++
expected output :
welcome c++
this work:
char s[50]; cin.get(s,50); (int = 0; < 50; i++){ if (s[i] == ' '){ s[i]='\n'; //suppose enter } } cout << s << endl;
Comments
Post a Comment