I read file, but in the end of file i get unknown symbols:
int main()
{
char *buffer, ch;
int i = 0, size;
FILE *fp = fopen("file.txt", "r");
if(!fp){
printf("File not found!\n");
exit(1);
}
fseek(fp, 0, SEEK_END);
size = ftell(fp);
printf("%d\n", size);
fseek(fp, 0, SEEK_SET);
buffer = malloc(size * sizeof(*buffer));
while(((ch = fgetc(fp)) != NULL) && (i <= size)){
buffer[i++] = ch;
}
printf(buffer);
fclose(fp);
free(buffer);
getch();
return 0;
}