ascii?

Jan 13, 2012 at 6:41pm
1
2
3
4
5
char greeting[]="Hello and welcome ";
char name[50];
cout<<question;
cin>>name;
cout<<endl<<greeting<<name;


I use this and it works for non-ascii characters.How can it be possible?(unicode?)
Jan 13, 2012 at 6:48pm
C++ (and C) I/O works with multibyte character strings, on platforms where that is supported.
This is normal :)

(as a side note, never do cin >> name where name is an array. Either make name a string, or use cin >> setw(50) >> name)
Last edited on Jan 13, 2012 at 6:49pm
Jan 13, 2012 at 7:00pm
(as a side note, never do cin >> name where name is an array. Either make name a string, or use cin >> setw(50) >> name)


You say that for purpose of displaying or is there any other problem with it?
Jan 13, 2012 at 7:01pm
I say that for the purpose of preventing buffer overflow exploits. As written, this program allows any malicious user execute any code by pasting it into the program's input.
Jan 13, 2012 at 7:03pm
Thanks for the reply Cubbi.
Topic archived. No new replies allowed.