1. 程式人生 > >bug:error:too few arguments to function ‘fopen’

bug:error:too few arguments to function ‘fopen’



#define File_Path "cpu_usepercentage_file.txt"

void open_file(){
 CPU_UsePercentage_File = fopen(File_Path,"ab");
 if(CPU_UsePercentage_File == NULL){
  printf("open CPU_UsePercentage_File error.\n");
  exit(0);
 }
}

報錯:

CPUUsePercentage.c:40:33: error: expected ‘)’ before ‘;’ token
CPUUsePercentage.c:40:33: error: too few arguments to function ‘fopen’

原來是因為define後面錯用了分號