1
void Check_file(char *filepath)
{
if(access(filepath, F_OK) == -1) {
printf("\nUnable to access : %s\n",filepath);
exit(1);
}
return;
}
void Check_file(char *filepath)
{
if(access(filepath, F_OK) == -1) {
printf("\nUnable to access : %s\n",filepath);
exit(1);
}
return;
}
當提供正確的包含文件時,您的程序compiles without complaint。
#include <stdio.h> /* needed for printf */
#include <stdlib.h> /* needed for exit */
#include <unistd.h> /* needed for access and F_OK */
void Check_file(char *filepath)
{
if(access(filepath, F_OK) == -1) {
printf("\nUnable to access : %s\n",filepath);
exit(1);
}
return;
}
int main() { return 0; }
發佈完整的代碼 – sujin
您應該'#include'所有的''爲'exit'和''爲'access'和''爲'printf';與所有3包括,我不會在Debian/Sid上用'gcc -Wall -c'得到警告;然而,;我建議使用'perror'或'strerror'(所以也包括''和'string.h')。你可能想編寫'exit(EXIT_FAILURE)'來提高可讀性! –
您可以將'-H'傳遞給'gcc'來理解包含哪些文件。 –