#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?
Answers were Sorted based on User's Feedback
Answer / sumant
the output will be RamcoSystems
but we need 2 more libraries
#include<string.h> and
#include<alloc.h>
to run this program. in else case it will not work.
| Is This Answer Correct ? | 6 Yes | 0 No |
Answer / 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 |
Answer / v.srinivasan
#include<stdio.h>
main()
{
char *p1,*p2;
p1 = (char *)malloc(25);
p2 = (char *)malloc(25);
strcpy(p1,"Ramco");
strcpy(p2,"Systems");
strcat(p1,p2);
printf("%s",p1);
}
the output will be RamcoSystems
we don't need the following libraries under Linux 2.6
#include<string.h> and
#include<alloc.h>
to run this program.
| Is This Answer Correct ? | 5 Yes | 0 No |
What is the method to save data in stack data structure type?
What is the difference between int main and void main in c?
how to add numbers without using arithmetic operators.
Write a C program that computes the value ex by using the formula ex =1+x/1!+x2/2!+x3+3!+………….
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference
Why can't we initialise member variable of a strucutre
Write a program to print numbers from 1 to 100 without using loop in c?
writw a program to insert an element in the begning of a doubly linked list
If null and 0 are equivalent as null pointer constants, which should I use?
What are the restrictions of a modulus operator?
write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.
Here is a neat trick for checking whether two strings are equal