我试图找出数组中哪些字符串以/结尾 但我不确定如何检查
for(int k = 0; k < num_paths; k++) {
path = malloc(strlen(paths[k]) + strlen(line) + 2);
if(path == NULL) {
exit(1);
}
if (paths[k] != '/') { // here is where I am trying to check
strcpy(path, paths[k]);
strcat(path, "/");
strcat(path, commands[0]);
if(access(path, X_OK) == 0) {
execv(path, commands);
error();
}
} else {
strcpy(path, paths[k]);
strcat(path, commands[0]);
if(access(path, X_OK) == 0) {
execv(path, commands);
error();
}
}
free(path);
}
我希望找到每个没有/
的字符串