חשוב מאוד!!!

liron6

New member
חשוב מאוד!!!

אם אני עושה את הפקודה הבאה: freopen("screen.txt", "wt", stdout) איך אני מבטלת אותה כדי שידפיס לי על המסך?
 

אלדד28

New member
את צריכה לפתוח מחדש את stdout

ולהפנות אותו למסך. באיזה פלטפורמה את עובדת?
 

אלדד28

New member
רגע, אם את משתמשת ב-freopen,

#include <stdio.h> int main() { FILE *fout1; FILE *fout2; fout1 = freopen("c:\\screen.txt", "wt", stdout); printf("Hello, world! (will be sent to the file)\n"); fclose(stdout); fout2 = freopen("con", "wt", stdout); printf("Hello, world! (will be sent to the screen)\n"); return 0; }​
 

eyalbd

New member
עכשיו לשאלה חשובה לא פחות

מדוע את רוצה לנתב את stdout לקובץ אחר? אולי יש אלטרנטיבה יותר פשוטה? מדוע לא כתיבה ישירה לקובץ ע"י fprintf?
 
כי זה מה שאמרו לה לעשות בתרגיל

נכון?
 
למעלה