f(char *p)
{
p=(char *)malloc(sizeof(6));
strcpy(p,"HELLO");
}
main()
{
char *p="BYE";
f(p)
printf("%s",p);
}
what is the output?
Answer Posted / yathish m yadav
the output is "hello".
here we are overwriting pointer *p thrice.
that is in the function we get an piece of memory from
malloc and assigned to p,
in the statement strcpy(p,"hello");
the malloc memory is lost and the compiler creates an char
array and copies the string "hello" and it makes the
character array as constant.
| Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
What is wrong with this program statement? void = 10;
using only #include
show how link list can be used to repersent the following polynomial i) 5x+2
c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above
1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.
How many loops are there in c?
what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321
Write a program for finding factorial of a number.
Write a program to print all permutations of a given string.
What does. int *x[](); means ?
How important is structure in life?
Which is more efficient, a switch statement or an if else chain?
What is p in text message?
Tell me can the size of an array be declared at runtime?