FILE *fp = NULL; fp = fopen("D://set.txt","a"); fprintf(fp,"%s",tmpBuffer); if (fp) { fclose(fp); fp = NULL; }