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
How many types of comments are there in c++?
Which programming language should I learn first?
What does the following code do: int c=0; cout< a) Undefined *Updated* b) 01 c) 00
When do you call copy constructors?
Specify some guidelines that should be followed while overloading operators?
What is data types c++?
What is a buffer c++?
What are references in c++? What is a local reference?
What is the sequence of destruction of local objects?
What is microsoft c++ redistributable?
What is data type in c++?
Which software is best for programming?
Search for: what is pair in c++?
What are separators in c++?
What is a multimap c++?