#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 is the difference between array and linked list in c?
What is conio h in c?
What is #include cctype?
What is a c token and types of c tokens?
please give me some tips for the placement in the TCS.
Write a C program to count the number of email on text
Why can arithmetic operations not be performed on void pointers?
How can I do peek and poke in c?
What are derived data types in c?
Differentiate between static and dynamic modeling.
Why we use void main in c?
What is extern storage class in c?
What is the correct declaration of main?
Explain what is meant by 'bit masking'?
What is anagram in c?