📄 ex0814.cpp
字号:
// Programming with C++, Second Edition, by John R. Hubbard
// Copyright McGraw-Hill, 2000
// Example 8.14 on page 194
// The strchr(), strrchr(), and strstr() functions
#include <cstring>
#include <iostream>
using namespace std;
int main()
{ char s[] = "The Mississippi is a long river.";
cout << "s = \"" << s << "\"\n";
char* p = strchr(s, ' ');
cout << "strchr(s, ' ') points to s[" << p - s << "].\n";
p = strchr(s, 's');
cout << "strchr(s, 's') points to s[" << p - s << "].\n";
p = strrchr(s, 's');
cout << "strrchr(s, 's') points to s[" << p - s << "].\n";
p = strstr(s, "is");
cout << "strstr(s, \"is\") points to s[" << p - s << "].\n";
p = strstr(s, "isi");
if (p == NULL) cout << "strstr(s, \"isi\") returns NULL\n";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -