Hello , I'm new on programming and I'm trying to pass one more step to files. I wrote the following code and opened the " dosya.txt " file to true folder. At first I wrote it to G:\\dosya.txt , then I got null character as a return. After this I changed it to C:\\dosya.txt , now I got
" Unhandled exception at 0x5521e42e (msvcr100d.dll) in asd.c.exe: 0xC0000005: Access violation writing location 0xcccccccc. " error and I don't know how to solve it. I think I didn't do anything wrong but my code doesn't work. Can you help me to solve this ? Thanks a lot :)
" Unhandled exception at 0x5521e42e (msvcr100d.dll) in asd.c.exe: 0xC0000005: Access violation writing location 0xcccccccc. " error and I don't know how to solve it. I think I didn't do anything wrong but my code doesn't work. Can you help me to solve this ? Thanks a lot :)
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,a[5];
FILE *ptr;
ptr = fopen("C:\\dosya.txt","r");
if(ptr==NULL)
printf("File does not exist !");
for(i=0;i<5;i++,ptr++)
{
fscanf(ptr,"%d",a[i]);
printf("%d\n",a[i]);
}
}
Comment