How to get output for files program in c

+1 vote
asked Nov 21, 2019 by Etikala Nikhil (130 points)
if we want to get output for file program, what to do,I am getting directly process finished without outputs

1 Answer

0 votes
answered Nov 24, 2019 by RAGE MONSTER rocks (570 points)
#include <stdio.h>

int main()
    int i=0;
    char ch[100];
    FILE *fp;
    // write();
    // fscanf(fp,"%s",ch);  //string will terminate uf we press space_bar.
    fgets(ch,100,fp);       //using fgets() allows us to get whole string.
    printf("\n\n\t\tread successfully  !!!");
    return 0;

change the name of the to which you want to to read

hope it will work !
commented Nov 25, 2019 by t c wu (100 points)
Is the file "file_name.txt" created and saved in onlinegdb ?  Thanks !
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.