ex0210.cpp

来自「Visual+C+++6[1].0实用教程代码 Visual+C+++6[1]」· C++ 代码 · 共 32 行

CPP
32
字号
// ex0210.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream.h>
#include <string.h>

int main(int argc, char* argv[])
{
char str1[30] = "Beijing 2008 ";
char str2[] = "Olympic Games";
char tmp1[60],tmp2[8], * tmp;
char str[] = "One World  One Dream";
strcpy(tmp1, str1);
strncpy(tmp2, str2, 7);
tmp2[5] ='\0';
cout << "运行strcpy函数的结果:" <<tmp1 << "\n";
cout << "运行strncpy函数的结果:" << tmp2 << "\n";
cout << "运行strcat函数的结果:" << strcat(str1, str2) << "\n";
cout << "运行strcmp函数的结果:" << strcmp(tmp2,"Happ") <<"\n";
cout << "运行strncmp函数的结果:" << strncmp(str1,"Happy",5) <<"\n";
//strtok function eg. 
tmp = strtok(str, " ");
while(tmp != NULL)
{
cout << tmp <<'\n';
tmp = strtok(NULL, " ");
}
cout << "运行strlen函数的结果:" << strlen(str2) <<"\n";
 return 0;
}

⌨️ 快捷键说明

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