int n; scanf("%d",&n); int *score; score=(int *)malloc(sizeof(int)*n); int i; for (i=0;i<n;i++) { scanf("%d",sizeof(int)*i+score); } printf("ok"); In the above code I get an error but when I comment the last line printf the program runs correctly. what is the problem?? (I want to give n number from user without using arrays)
scanf("%d",sizeof(int)*i+score);-->scanf("%d",&score[i]);andscore=(int *)malloc(sizeof(int)*n);-->score=malloc(sizeof(int)*n);scanf("%d",score+i);scanf("%d", &score[i]);. And check return value of scanf.