+7

Please explain output

https://code.sololearn.com/c8C8oz20o345/?ref=app

3/24/2020 12:09:22 PM

SKR

10 Answers

New Answer

+2

This program is printing the number of every iteration and the address of that variable. That is why it is never the same address Look at this to see it easier: https://code.sololearn.com/cWN4QKyx6ZoX/?ref=app

+7

Hatsy Rei it prints others no. In between -256 to 255 What does it mean https://www.sololearn.com/post/273333/?ref=app these in between values change with time

+6

Hatsy Rei thanks

+6

amit avinoam thanks

+5

i is an integer. b is a char pointer. To inspect the output better, try doing printf ("%d %d\n",i,b); i assumes values from -256 to 255. b simply doesn't change (and the address is printed in integer format). Nothing really out of the ordinary.

+5

DARK WEB🕸●➷➹● As mentioned, those are the address stored in char pointer b. The location of where your variable is in the system depends on the compiler, and may vary on each run. https://stackoverflow.com/questions/49014506/

+5

It prints numbers between - 255 to 255 but it is hard to read because right after printing a number it prints the content of b variable witch is an address in hexadecimal form so we can't use %d for that instead we should use %p to print it's actual content. Try this: https://code.sololearn.com/cadbjQc4hVC9/?ref=app

+4

First two integers are declared (a and i). Then, a pointer variable is declared(b) in which the address of one of the integers (a) is stored. Then a simple for loop is created which iterates from -256 to 255 ie. it iterates 512 times. Then in each iteration, the value stored in the pointer variable(b) and counter variable(i) is printed to the screen.

+3

Thank you for explaining

+2

It prints two numbers without space simultaneously. One is the variable i which varries from -255 to 255 as your instruction in the for loop. Other is address of variable b, which is constand. Since you haven't made any provision for spaces,it is difficult to gather output....