使用库函数strcmp比较。
strcmp是C语言比较字符串的库函数。形式为int strcmp,该函数会对a和b的每个字符,按照ascii码值比较,如果二者完全相同返回0;如果a的ascii码值先出现较大者,会返回1;否则返回-1。所以,要判断字符串相等,可以使用if(strcmp(string1, string2) =0)如果返回为0,则相等,否则不等。
位置:首页>生活家居>在C语言中怎样判断汉字相等 c语言 判断字母
使用库函数strcmp比较。
strcmp是C语言比较字符串的库函数。形式为int strcmp,该函数会对a和b的每个字符,按照ascii码值比较,如果二者完全相同返回0;如果a的ascii码值先出现较大者,会返回1;否则返回-1。所以,要判断字符串相等,可以使用if(strcmp(string1, string2) =0)如果返回为0,则相等,否则不等。
生活家居时间:2023/8/3 4:56:30
生活家居时间:2023/7/19 5:53:10
生活家居时间:2023/8/3 5:09:31
生活家居时间:2023/8/3 4:40:58
生活家居时间:2023/7/17 4:41:45
生活家居时间:2023/7/7 17:24:28
生活家居时间:2023/7/2 15:32:47
生活家居时间:2023/7/10 10:31:03
生活家居时间:2023/8/3 4:23:00
生活家居时间:2023/7/3 11:45:20