main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}
what is the output?
Answer Posted / vint
int main()
{
char *p1="Name";
char *p2,*s1,*s2;;
p2=(char *)malloc(20);
s1 = p1;
s2 = p2;
while(*p2++ = *p1++);
printf("%s %s",s1,s2);
return 0;
}
Store the Start address of p1 and p2 before incrementing the pointer so that it could be later used to print the String.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How can I delete a file?
while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above
Do you know what are bitwise shift operators in c programming?
What is pointers in c?
main(){char *str;scanf("%s",str);printf("%s",str); }The error in the above program is: a) Variable 'str' is not initialised b) Format control for a string is not %s c) Parameter to scanf is passed by value. It should be an address d) none
How can I recover the file name given an open stream?
What are the types of data files?
What is the difference between test design and test case design?
What are the advantages and disadvantages of pointers?
You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.
Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......
How do you redirect a standard stream?
How do you initialize pointer variables?
writ a program to compare using strcmp VIVA and viva with its output.
How do I get a null pointer in my programs?