while循环是没有初始化和更i性能部分的for循环,他只有测试条件和循环体,执行完循环体中的语句,程序返回测试条件,对他重新进行评估,如果该条件非零,则再次执行循环体,测试和执行一直进行下去,直到评估测试条件为false是结束循环。所以一定要注意循环条件,避免进入死循环。
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#include <iostream> using namespace std; const int ArSize = 20; int main() { char name[ArSize]; cout << "Your first name,please: "; cin >> name; cout << "Here is your name,verticalized and ASCIIized:n"; int i = 0; while (name[i] != '') { cout << name[i] << ": " << int(name[i]) << endl; i++; } system("pause"); return 0; }
最后
以上就是专注含羞草最近收集整理的关于C++While循环:遍历字符串,显示对应ASCII码值的全部内容,更多相关C++While循环:遍历字符串内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复