← 返回列表

C库 freopen()

C库 freopen() #include <stdio.h> int main () { FILE *fp; printf("This text is redirected to stdout\n"); fp = freopen("file.txt", "w+", stdout); printf("This text is redirected to file.txt\n"); fclose(fp); return(0); }

C库 freopen()

#include <stdio.h>



int main () {

   FILE *fp;



   printf("This text is redirected to stdout\n");

   fp = freopen("file.txt", "w+", stdout);



   printf("This text is redirected to file.txt\n");

   fclose(fp);



   return(0);

}

打开资源 ↗

交流与评论