0

void function(int a, int b, int c){
char buffer1[5];
char buffer2[10];
int *r;
r = buffer1 + 12;
(*r) += 8;
}
int main(){
int x = 0;
function(1,2,3);
x = 1;
printf("x = %d\n", x);
}

Hi,

I am new to this community and have joined recently. I am trying to run this program and on compiling it gives warning as "assignment from incompatible pointer type". I wanted to know why this happens that is the reason behind this warning?

Also Besides i need to use a debugger such as gdb to find out why the program is outputting the current output of x=1? And how do i provide a memory dump of the stack? Also in my opinion the program should have given output as x=0 but it gave output as x=1? So how do i modify the program so that it gives the output as x=0?

I am new to the C language and have plenty of doubts. Please reply at the earliest?

Rohan

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by C-er
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.