printf(3 + "goodbye");

"goodbye" is a character array.

If we assume base address of the character array "goodbye" as 1024.

The starting address points to the character 'g'.




3 + "goodbye" or "goodbye" + 3

3 + "goodbye" will be (base address + 3 which is 1027).(size of character is 1 byte.)

Now the starting address is 1027 which points the character 'd'.


printf will print the given message from the starting address to the end.

Here, starting address has changed to 1027.

So, it will print "dbye"


goodbye+3 printf

#include<stdio.h>

int main()
{
    printf(3 + "goodbye");

    return 0;
}

Output

dbye




"goodboy" + 4

Now the starting address of the character array "goodbye" is 1024+4 = 1028.

1028 is the address of the character 'b'.

So, it will print bye

#include<stdio.h>

int main()
{
    printf("goodbye" + 4);

    return 0;
}

Output

bye


Topics You Might Like