469,909 Members | 1,683 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,909 developers. It's quick & easy.

abt white spaces n charecter arrays

86
well i need to deal with white spaces in charecter arrays...

with static arrays its fine..

char ss[50];

cin.getline(ss, sizeof ss);

.... //deals with white spaces

cout<<"Formatted ss :"<<ss;


but the problem m facing s with dynamic char array..

char * ss =new char;
now i cant use cin.getline(..) here as i declared pointer....and using cin eleminates the possiblity f dealn with white spaces as it ignores white spaces..

using string s also not helpful..

PLEASE HELP ASAP....
Apr 1 '07 #1
3 1633
Banfa
9,065 Expert Mod 8TB
char * ss =new char;
now i cant use cin.getline(..) here as i declared pointer
Yes you can, cin takes a char * as input.
I suggest you check the getline reference.
Apr 1 '07 #2
ayan4u
86
ok fine..thnx but since i have to use the size limit n getline....the usefulnss f dynamic array is rendered useless as how wld i know bfore hand the no f chars to entrd durin run time.....
Apr 1 '07 #3
ayan4u
86
okies i fixed....using string instead f char*...

string ss;

getline(cin,ss);

thnx admin....
Apr 1 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by qwweeeit | last post: by
4 posts views Thread by ucfcpegirl06 | last post: by
11 posts views Thread by gopal srinivasan | last post: by
3 posts views Thread by Prince | last post: by
4 posts views Thread by Andreas Prilop | last post: by
12 posts views Thread by JA | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.