I'm getting a few extra garbage characters after I print out the file I've read into an array.
Here is my code
fp = fopen("load.txt", "r");
if (fp == NULL)
{
perror("Exiting, an error occured while opening\n");
exit(EXIT_FAILURE);
}
while((ch = fgetc(fp)) != EOF)
{
load[i++] = ch;
}
fclose(fp);
for(i = 0; i < 100; ++i)
{
printf("%c", load[i]);
}
Sample output
The quick brown fox jumped over the lazy dog.
���������0LãUˇ���∞4
����������@LãUˇ��������������
Notice all of the garbage after the sentence? I'm not sure what is causing this.
Thanks in advance for any help
loaddeclaration.