Here is my code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZEWORD 1000
#define SIZECHAR 80
int main(void)
{
//Local Declarations
FILE* fh;
char word[SIZEWORD];
int timesinfile[SIZEWORD],n;
//Open file
if(!(fh = fopen("story","r")))
{
printf("ERROR");
exit(100);
}
fh = fopen("story","r");
//Putting in string
for(n = 0;n < 4;n++)
{
fscanf(fh,"%s",word[n]);
printf("%s",word[n]);
}
fclose(fh);
return(0);
}
The file story contains "This is a test to see if I can read in words"
I am getting (null) (null) (null) (null) when i need it to say This is a test
Eventually I will change it so it reads in until the end of file but for now I can't even get the first words.
Any Help would be appreciated.

New Topic/Question
Reply




MultiQuote






|