1)#include <iostream.h>
int main()
{
int *a, *savea, i;
savea = a = (int *) malloc(4 * sizeof(int));
for (i=0; i<4; i++) *a++ = 10 * i;
for (i=0; i<4; i++) {
printf("%d\n", *savea);
savea += sizeof(int);
}
return 0;
}
2)#include <iostream.h>
int main()
{
int *a, *savea, i;
savea = a = (int *) malloc(4 * sizeof(int));
for (i=0; i<4; i++) *a++ = 10 * i;
for (i=0; i<4; i++) {
printf("%d\n", *savea);
savea ++;
}
return 0;
}
The output of this two programs will be different why?
Answer Posted / mahesh
first program prints sum of saved and size of int
second one prints only the contenst of saved
| Is This Answer Correct ? | 2 Yes | 3 No |
Post New Answer View All Answers
What is a multiset c++?
What are pointer-to-members in C++? Give their syntax.
Can we get the value of ios format flags?
Refer to a name of class or function that is defined within a namespace?
What is Destructor in C++?
Which operator cannot be overloaded c++?
What is the use of setfill in c++?
What is the difference between the functions memmove() and memcpy()?
Is c++ the hardest language?
How a new element can be added or pushed in a stack?
What are the basic data types used in c++?
Is c++ an oop?
What is boyce codd normal form in c++?
State two differences between C and C++.
Why iomanip is used in c++?