C language simple input and output. I need aprogram, that prints out the input from the keyboard toa specific file. This code let me to enter the input but I don'tsee the saved output in a created file. Why? How to fix it?
#include<stdio.h>#include<stdlib.h>
int main(void){ char ch[100]; FILE* fp; if(!(fp = fopen("RandomFile1.txt", "r"))){ printf("\aCannot open thefile.\n"); exit(100); } while(fgets(ch, sizeof(ch), stdin)){ fputs(ch, fp); } fclose(fp); return 0;}
C language simple input and output. I need a program, that prints out the input from the keyboard to a specific file. T
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am