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

Why do people keep posting the same problem in every forum they can find?

Devshed Forums

And again; read this first:

READ THIS BEFORE POSTING

commented: It's a mystery which baffles anyone with the ability to think past the immediate problem +23
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.