🧠Output Explanation
When you run the program, it shows:
enter the content of the file, press cntrl+z when finish
File 1 ➞ File 2
the content of the copied file: File 1
Step-by-step meaning:
enter the content...→ Program asks you to type text for File 1 (input).File 1 ➞ File 2→ This is the text you typed; it’s stored inside the input file.the content of the copied file→ Printed by the program before showing copied data.File 1 ➞ File 2→ The same content displayed again, this time read from File 2 (output).
Notice there’s no line break between the content of the copied file and your copied text — because the program’s printf() doesn’t include \n.
⚙️ Extra Points (Advanced Concepts)
- clrscr() → Clears the Turbo C screen (non-standard, used for visual reset).
- (ch = getchar()) != EOF → Reads every character until Ctrl+Z (end of input).
- putc(ch, fp) → Writes each character directly to file (efficient).
- fcloseall() → Turbo C–specific function that closes all open files (not ANSI C standard).
- Copy Process:
while((ch=getc(fp))!=EOF) putc(ch, fp1);→ Copies input to output exactly, preserving formatting. - Output Formatting Issue → Missing
\ncauses continuous line display. - getch() → Keeps the output window open until a key is pressed.
🧾 In Short
| Stage | File | Purpose |
|---|---|---|
| 1. Input | input |
You type data here (File 1) |
| 2. Copy | output |
Program duplicates input into this file (File 2) |
| 3. Display | Console | Shows copied content from File 2 |
OR Download
Please Wait, Files are Loading...
Please wait 15s
