Skip to content

Instantly share code, notes, and snippets.

View bhanubais's full-sized avatar

Bhanu Pratap Singh bhanubais

View GitHub Profile
@bhanubais
bhanubais / pointer_issue.c
Created April 6, 2017 18:54
C language pointer issue. Why I am getting 20 instead of 7 as a value of *nn in following code?
#include <stdio.h>
int *ptr(int n);
void nothing(int n1);
int main(void) {
int *nn = ptr(7);
nothing(20);
printf("*nn is %d\n", *nn); // why I am getting 20 instead of 7?
}
@bhanubais
bhanubais / pointer_issue.c
Created April 6, 2017 18:54
C language pointer issue. Why I am getting 20 instead of 7 as a value of *nn in following code?
#include <stdio.h>
int *ptr(int n);
void nothing(int n1);
int main(void) {
int *nn = ptr(7);
nothing(20);
printf("*nn is %d\n", *nn); // why I am getting 20 instead of 7?
}