#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
Does c have enums?
What are comments and how do you insert it in a C program?
write a c program to calculate sum of digits till it reduces to a single digit using recursion
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
Where are c variables stored in memory?
What is a void pointer? When is a void pointer used?
Why we use void main in c?
Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.
Differentiate between a structure and a union.
How to write a program for machine which is connected with server for that server automatically wants to catch the time for user of that machine?
Why is #define used?
List a few unconditional control statement in c.
hi, which software companys will take,if d candidate's % is jst 55%?
What is equivalent to ++i+++j?
Explain how can I pad a string to a known length?