if i don't use gets(),how can i do that?
djfiejf fjiejfi fjeifjef -> char a[255]
cin.readLine()?how to use it?
how can i input a string which has spaces into a char array?
Moderator: Board moderators
how can i input a string which has spaces into a char array?
"Learning without thought is useless;thought without learning is dangerous."
"Hold what you really know and tell what you do not know -this will lead to knowledge."-Confucius
"Hold what you really know and tell what you do not know -this will lead to knowledge."-Confucius
one possibility: (I'm not sure whether getline works with a char array, but this should work.)
Code: Select all
string S;
getline(cin,S);
// now you either use S.c_str(), or:
char ch[100];
int sl=S.length();
for (int i=0;i<sl;i++) ch[i]=S[i];
-
- Guru
- Posts: 584
- Joined: Thu Jun 19, 2003 3:48 am
- Location: Sanok, Poland
- Contact: