Hi,
I'm curious about a behavior I observed. This is based on a question I attempted to answer in a different group.
Code snippet:
#include <iostream>
using namespace std;
int main () {
int i;
cout << "Input something: ";
cin >> i;
cout << "i=" << i << endl;
}//end main
If the user inputs the character L, i is displayed as zero. Why is it not 76? It seems like the input buffer would have to have the ASCII code for L in it and that that value would be fed to the program and appropriately promoted to the int data type with no loss of data. Obviously I don't understand what's happening here. Any clarification here would be greatly appreciated.
Thanks,
Frank
I'm curious about a behavior I observed. This is based on a question I attempted to answer in a different group.
Code snippet:
#include <iostream>
using namespace std;
int main () {
int i;
cout << "Input something: ";
cin >> i;
cout << "i=" << i << endl;
}//end main
If the user inputs the character L, i is displayed as zero. Why is it not 76? It seems like the input buffer would have to have the ASCII code for L in it and that that value would be fed to the program and appropriately promoted to the int data type with no loss of data. Obviously I don't understand what's happening here. Any clarification here would be greatly appreciated.
Thanks,
Frank