第3个回答 2011-03-05
#include <string.h>
void main(int argc,char *argv[])
{
if (argc!=3)
printf("请在运行程序时提供两个字符串参数!例如:testApp aaa bbb\n");
else
{
if (strcmp(argv[1],argv[2])>0)
printf("字符串1大于字符串2");
else if(strcmp(argv[1],argv[2])<0 )
printf("字符串1小于字符串2");
else
printf("字符串1等于字符串2");
}
}
把上述程序保存为testApp.cpp,然后编译为testApp.exe文件,最后在命令行模式下按“testApp 字符串1 字符串2”的格式输入命令,即可看到结果。本回答被提问者采纳