安川机器人编程手册:C++字符串比较,将比较值送给以个变量。

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/15 09:11:58
例如:
cahr pass[11]='1111111111';
char password='1111111111';
char p;

将pass 和password 的比较结果送给p,请问应给怎么样实现。

#include <string.h>
p=strcmp(pass,password);
//0为相等,负数为右边大于左边,正数为左边大于右边
你的定义都错了

char pass[11]="1111111111";
char password[]="1111111111";
int p; //比较结果最好用int来存,不要用char

字符串数组能和字符串进行比较吗
比较的话,也是他们的地址吧