f0304.cpp

来自「it is a usefull thing」· C++ 代码 · 共 21 行

CPP
21
字号
//=====================================
// f0304.cpp
// C串操作
//=====================================
#include<iostream>
using namespace std;
//-------------------------------------
int main(){
  char* s1 = "Hello ";
  char* s2 = "123";
  char a[20];
  strcpy(a, s1);                                      // copy
  cout<<(strcmp(a,s1)==0 ? "" : " not")<<"equal\n";   // compare
  cout<<strcat(a, s2)<<endl;                          // concatenate
  cout<<strrev(a)<<endl;                              // modify
  cout<<strset(a, 'c')<<endl;                         // set
  cout<<(strstr(s1, "ell") ? "" : "not ")<<"found\n"; // find string
  cout<<(strchr(s1,'c') ? "": "not ")<<"found\n";     // find char
}//====================================

 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?