I am trying to read a file and print the data to the screen. This is what the code looks like so far.
Code:#include <stdio.h> #include <string.h> #include <stdlib.h> char a[50]; int i; FILE *fp; int main() { fp = fopen("PSV101data.rtf", "r"); for (i=1; i <= 47; i++) {fscanf(fp, "%s\n", a[i]); printf("%s/n", a[i]);} fclose(fp); return 0; }
This is the output
(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/n(null)/
I am trying to just read one line at a time and output one line at a time. Any suggestions would be appreciated.