#include <iostream.h>
#include <string.h>
void main( )
{
char str1[6],str2[6],str3[6],temp[6];
cout<<"Please input 3 strings:"<<endl;
cin>>str1>>str2>>str3;
//自己写排序过程。
cout<<"str1:"<<str1<<endl;
cout<<"str2:"<<str2<<endl;
cout<<"str3:"<<str3<<endl;
提示:
(1)字符串的拷贝函数strcpy
格式:strcpy(字符数组名1,字符数组名2)
举例: strcpy(str1,str2);
(2)字符串的比较函数strcmp格式: strcmp(字符数组名1,字符数组名2)
如果: 字符串1=字符串2 ,返回值=0
字符串1>字符串2 ,返回值>0
字符串1<字符串2 ,返回值<0
这个程序不是你都写过了吗,只是有些错误
程序修改的地方:
1、添加命名空间
using namespace std; // 添加命名空间引用2、主函数和大括号对调,并改主函数类型为 int
int main() // 主函数和大括号的位置对调一下完整的修改后代码如下:
#include <iostream>