#include <iostream>
main() {
int a = 0;
static char buffer[20] = "hello";
cout << "Enter [uid] [command]: ";
cin >> a >> buffer;
cout << "Okay, executing " << buffer << " as user " << a << endl;
}
When I run this program with the input "ls100" then it prints
"Okay, executing as user user 0".
but almost a same program in C writes
"Okay, executing hello as user 0"
Why doesn't C++ do the same? I mean why it doesn't print "hello", the
initial value......scanf does (C)?
main() {
int a = 0;
static char buffer[20] = "hello";
cout << "Enter [uid] [command]: ";
cin >> a >> buffer;
cout << "Okay, executing " << buffer << " as user " << a << endl;
}
When I run this program with the input "ls100" then it prints
"Okay, executing as user user 0".
but almost a same program in C writes
"Okay, executing hello as user 0"
Why doesn't C++ do the same? I mean why it doesn't print "hello", the
initial value......scanf does (C)?