fopen - input from keyboard to a text file in c?? The Code compiles but *EOF* don't works? -


<पूर्व> #include & lt; stdio.h & gt; Int main () {FILE * pFile; चार च; PFile = fopen ("जी: \\ IJLAL.txt", "w +"); जबकि ((ch = getchar ())! = EOF) putc (ch, pFile); fclose (pFile); वापसी 0; }

क्या आप समस्या को निर्दिष्ट कर सकते हैं ??? मैं फ़ॉपन फ़ंक्शन के लिए पूरी तरह से नया हूँ और कृपया मुझे इस चीज़ के साथ मदद करें

getchar () फ़ंक्शन एक देता है int मान, नहीं एक char । इसे एक char वेरिएबल में मजबूर करके, आप इसे EOF का पता लगाना असंभव बना रहे हैं।

बस char ch से int ch < / कोड> और यह ठीक काम करेगा। *


  • असल में, आपको शायद फाइल नाम के साथ समस्याएं होंगी। क्या आप सुनिश्चित हैं कि इसमें एक स्थान होना चाहिए? और क्या आप जानते हैं कि \\ को एक एकल बैकस्लैश वर्ण के रूप में एन्कोड किया गया है?

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -