strcmp、strcpy函数的用法
例子代码:
#include <stdio.h>
#include <string.h>
main()
{
char s1[10]=”China”;
char s2[10]=”America”;
char s3[10]=”Japan”;
char t[10];
if(strcmp(s1,s2)>0)
{
strcpy(t,s1);strcpy(s1,s2);strcpy(s2,t);
}
if(strcmp(s2,s3)>0)
{
strcpy(t,s2);strcpy(s2,s3);strcpy(s3,t);
}
puts(s1);puts(s2);puts(s3);
}
strcmp字符串的比较,strcpy字符串的拷贝。
运行结果:
[nagios@TestServer-RHAS-5 c]$ ./daima3
America
China
Japan
详细用法见下面的解释页面。
http://baike.baidu.com/view/1026924.htm
http://baike.baidu.com/view/1026861.htm
捐赠本站(Donate)
如您感觉文章有用,可扫码捐赠本站!(If the article useful, you can scan the QR code to donate))
- Author: shisekong
- Link: https://blog.361way.com/strcmpcpy/422.html
- License: This work is under a 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. Kindly fulfill the requirements of the aforementioned License when adapting or creating a derivative of this work.