Select Menu

Slider

Software's

Transportation

Cement Testing

Inventor

Manual Survey Practical

Quantity Surveying

Videos

» » To Read a string of text from file (C-Programming)
«
Next
Newer Post
»
Previous
Older Post


#include <stdio.h> #include <stdlib.h> /* For exit() function*/ int main() { char c[1000]; FILE *fptr; if ((fptr=fopen("program.txt","r"))==NULL){ printf("Error! opening file"); exit(1); /* Program exits if file pointer returns NULL. */ } fscanf(fptr,"%[^\n]",c); printf("Data from file:\n%s",c); fclose(fptr); return 0; }

«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Post Your Comments