lesson 7 cin char cpp
[[lesson_7_cin_char_cpp]] last edit on
Aug 10, 2005
3:15 AM
by rescued_by_c
[user02@FC4 Lesson07]$ cat -n cin_char.cpp
[user02@FC4 Lesson07]$ ./cin_char
Type any character and press Enter: R
The letter typed was R
[user02@FC4 Lesson07]$ ./cin_char
Type any character and press Enter: Word
The letter typed was W
1 #include <iostream>
2 using namespace std;
3
4 int main()
5 {
6 char letter;
7
8 cout << "Type any character and press Enter: ";
9 cin >> letter;
10 cout << "The letter typed was " << letter << endl;
11
12 return 0;
13 }
[user02@FC4 Lesson07]$ g++ -o cin_char cin_char.cpp[user02@FC4 Lesson07]$ ./cin_char
Type any character and press Enter: R
The letter typed was R
[user02@FC4 Lesson07]$ ./cin_char
Type any character and press Enter: Word
The letter typed was W