C語言strcmp函式使用
阿新 • • 發佈:2020-09-12
static struct usb_function_instance *try_get_usb_function_instance(const char *name) { struct usb_function_driver *fd; struct usb_function_instance *fi; fi = ERR_PTR(-ENOENT); mutex_lock(&func_lock); list_for_each_entry(fd, &func_list, list) { if (strcmp(name, fd->name))continue; if (!try_module_get(fd->mod)) { fi = ERR_PTR(-EBUSY); break; } fi = fd->alloc_inst(); if (IS_ERR(fi)) module_put(fd->mod); else fi->fd = fd; break; } mutex_unlock(&func_lock);return fi; }
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <pthread.h> #include <semaphore.h> #include <unistd.h> #include <signal.h> #include <string.h> // static static char* name[] = {"uac","uvc","back","fprint"}; int main() { int i = 0; while(i++<10) { if(strcmp(name[i],"uac")) { printf("string is not the same \n"); continue; } } while(1); return 0; }
C/C++函式,比較兩個字串 設這兩個字串為str1,str2, 若str1==str2,則返回零; 若str1<str2,則返回負數; 若str1>str2,則返回正數。 matlab中函式,strcmp(s1,s2) 判斷兩個字串s1和s2是否相同,相同返回true ,不同返回false