I am trying basic c program using pointers, Here's my code
#include <stdio.h>
int main()
{
int *p;
for(int i=0;i<10;i++){
*p = &i;
printf("%d",*p);
}
return 0;
}
Output:
main.c:16:12: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
*p = &i;
^
...Program finished with exit code 0
And the value is not printed. Is there any problem in assigning variable i
which persists from for loop to pointer?