#include<stdio.h>
main()
{
char *p1;
char *p2;
p1=(char *) malloc(25);
p2=(char *) malloc(25);
strcpy(p1,"Ramco");
strcpy(p2,"Systems");
strcat(p1,p2);
printf("%s",p1);
}
Tell me the output?
Answer Posted / mage
The program is not correct. What is present in memory
beyond "Ramco" is not known and we are trying to
attach "Systems". May be we are overwriting something which
is unsafe.
To concatenate two strings declare the first as array.
example: char p1[50];
char *p2;
p2 = malloc(25);
strcpy(p1, "Ramco");
strcpy(p2,"Systems");
strcat(p1,p2);
| Is This Answer Correct ? | 7 Yes | 1 No |
Post New Answer View All Answers
What are the data types present in c?
process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,
How to declare pointer variables?
What are multidimensional arrays?
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
What is restrict keyword in c?
Is printf a keyword?
What is graph in c?
Write a program to print fibonacci series without using recursion?
What is the use of define in c?
What is page thrashing?
What are the 4 types of organizational structures?
What does p mean in physics?
Explain how can I pad a string to a known length?
Explain what is a program flowchart and explain how does it help in writing a program?