GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — programming-c-cpp-learning/string1.cpp at master · eeyoo/programming-c-cpp-learning Expand file tree/ Copy pathstring1.cppMore file actions 37 lines (31 loc) · 1.03 KB / Copy pathstring1.cppFile metadata and controls37 lines (31 loc) · 1.03 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 /** * c++中大量的函数用来操作以null结尾的字符串 * supports a wide range of functions that manipulate null-terminate strings * strcpy(s1, s2) - 复制字符串s2到字符串s1 * strcat(s1, s2) - 连接字符串s2到字符串s1的末尾 * strlen(32) - 返回字符串s1的长度 * strcmp(s1, s2) - 先猜猜看 * strchr(s1, ch) - 返回一个指针,指向字符串s1中ch首次出现的位置 * strstr(s1, s2) - 返回一个指针,指向字符串s1中字符串s2首次出现的位置 */ #include <iostream> #include <cstring> using namespace std; int main() { char str1[10] = "Hello"; char str2[10] = "World"; char str3[10]; int len; // copy str1 to str3 strcpy(str3, str1); cout << "strcpy( str3, str1 ) : " << str3 << endl; // connect str1 and str2 strcat(str1, str2); cout << "strcat( str1, str2 ) : " << str1 << endl; // get length of str1 len = strlen(str1); cout << "strlen( str1 ) : " << strlen(str1) << endl; cout << "strlen( str1 ) : " << len << endl; return 0; } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |