hey people!!
Need a little help if someone has five minutes.
I'm trying to write some code to read from a file, without
knowing the exact length of the file, if you know what i mean.
This is what i've come up with.
Code:
#include<stdio.h>
#include<stdlib.h>
FILE*fptr;
main()
{
int i;
char *m[5];
char why[16];
fptr=fopen("c:\\MYTEST ", "w+");
fprintf(fptr,"hello to whole world...whats goin down in happyville??\n");
fseek(fptr, 0, SEEK_SET);
while(!feof(fptr))
{
gets(why);
if(!feof(fptr))
{
for(i=0;i<5;i++)
{
m[i]= (char*) malloc(10*1);
}
}
}
printf("%s %s %s %s %s %s", why,m[0],m[1],m[2],m[3],m[4]);
fclose(fptr);
getchar();
}
this code doesnt actually work, hence my call for help. The creation of
the file works however when it gets to the 'while' something must go wrong
because my command window just shows a blank.
i'm sure its obvious that i'm a little new to this and
i'm probably trying to run before i can walk but if someone can give
me a little insight into how this sort of thing is done
i'd be real greatful