📄 cstring_iter.cpp
字号:
#include <iostream>#include <cstring>#include <cctype>using namespace std;int main(){ char word[] = "hello"; // Random-access iteration for ( unsigned int i = 0; i < strlen(word); i++ ) word[i] = toupper( word[i] ); cout << word << endl; // The same iteration, using a pointer, // is actually more efficient, because // incrementing is a cheaper operation // than the regular addition carried out // by the compiler to compute the address // of word[i] char *cp = word; while ( *cp != '\0' ) *cp++ = tolower( *cp ); for ( char *cp = word; *cp != '\0'; cp++ ) *cp = tolower( *cp ); cout << word << endl;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -