main()
{
int *ptr=(int*)malloc(sizeof(int));
*ptr=4;
printf("%d",(*ptr)+++*ptr++);
}

Answer Posted / john lee

main()
{
int *ptr=(int*)malloc(sizeof(int));
*ptr=4;
printf("%d",(*ptr)++ + (*ptr)++);
}

Like above, code should be revised as allocated memory space just has 2(16bit machine) or 4 byte(32bit machine) to save '4'.
If not, the orginal code, printf("%d",(*ptr)++ + *ptr++);

In my guess, ptr++ will be first, and then *ptr would be next.
If so, ptr++ will point to a memory address unintended(an address +2 or +4 added). And then *ptr will have a value like 0 or else.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

#include int main(void) { int a=4, b=2; a=b<>2 ; printf("%d",a); return 0; }

1323


Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?

4110


What is data _null_? ,Explain with code when u need to use it in data step programming ?

3047


How can I Create a C program in splitting set of characters to specific subsets. Example: INPUT SET OF CHARACTERS: Therefore, my dear brothers and sisters, stand firm. Let nothing move you. Always give yourselves fully to the work of the Lord, because you know that your labor in the Lord is not in vain. SPLIT INTO HOW MANY CHARACTERS PER SUBSETS: 10 OUTPUT: Therefore, my dear b rothers an d sisters, stand fir m. Let not hing move you. Alway s give you rselves fu lly to the work of t he Lord, b ecause you know that your labo r in the L ord is not in vain.

2198


write a program for area of circumference of shapes

2265


why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?

2534


How do you verify if the two sentences/phrases input is an anagram using predefined functions in string.h and by using arrays?

2281


how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.

2380


could you please send the program code for multiplying sparse matrix in c????

3314


Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange

3104


How can you relate the function with the structure? Explain with an appropriate example.

3147


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

2593


Design an implement of the inputs functions for event mode

3208


write a simple calculator c program to perform addition, subtraction, mul and div.

3416


Set up procedure for generating a wire frame display of a polyhedron with the hidden edges of the object drawn with dashed lines

3289