If I understand your question, look at fseek() and ftell()...
Also your going to get overflow if you read more than 100 characters (sizeof(filename)).
Also
Code:
filename[i] = '\0';
Will never get reached.
Why not just use fgets(), instead of brewing your own?
Consider:
Code:
/* ... */
FILE * fp;
char buff[100];
if((fp = fopen("file.txt", "rt")) == NULL)
{
perror("Failed to open file.txt");
exit(0);
}
while(fgets(buff, sizeof(buff), fp) != NULL)
{
printf("Filename: %s\n", buff);
}
fclose(fp);
/* ... */