#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
How do I get an accurate error status return from system on ms-dos?
What are the advantages of external class?
how can use subset in c program and give more example
Are local variables initialized to zero by default in c?
`write a program to display the recomended action depends on a color of trafic light using nested if statments
How will you declare an array of three function pointers where each function receives two ints and returns a float?
What are different types of variables in c?
What is typedf?
How is a null pointer different from a dangling pointer?
what are the different storage classes in c?
What is string concatenation in c?
Write a code to remove duplicates in a string.
What is dangling pointer in c?
Is main is user defined function?
The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference