while.cpp 574 B

123456789101112131415161718192021
  1. // while.cpp -- introducing the while loop
  2. #include <iostream>
  3. const int ArSize = 20;
  4. int main()
  5. {
  6. using namespace std;
  7. char name[ArSize];
  8. cout << "Your first name, please: ";
  9. cin >> name;
  10. cout << "Here is your name, verticalized and ASCIIized:\n";
  11. int i = 0; // start at beginning of string
  12. while (name[i] != '\0') // process to end of string
  13. {
  14. cout << name[i] << ": " << int(name[i]) << endl;
  15. i++; // don't forget this step
  16. }
  17. // cin.get();
  18. // cin.get();
  19. return 0;
  20. }