#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



#include<stdio.h> main() { char *p1; char *p2; p1=(char *) malloc(25); p2=(char *) m..

Answer / fazlur rahaman naik

The output will b : RamcoSystems

Is This Answer Correct ?    17 Yes 0 No

#include<stdio.h> main() { char *p1; char *p2; p1=(char *) malloc(25); p2=(char *) m..

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

#include<stdio.h> main() { char *p1; char *p2; p1=(char *) malloc(25); p2=(char *) m..

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

#include<stdio.h> main() { char *p1; char *p2; p1=(char *) malloc(25); p2=(char *) m..

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

#include<stdio.h> main() { char *p1; char *p2; p1=(char *) malloc(25); p2=(char *) m..

Answer / khaja

ramco system

Is This Answer Correct ?    3 Yes 1 No

#include<stdio.h> main() { char *p1; char *p2; p1=(char *) malloc(25); p2=(char *) m..

Answer / mastan vali.shaik

25Ramco25Systems

Is This Answer Correct ?    2 Yes 13 No

Post New Answer

More C Interview Questions

What are the rules for identifiers in c?

0 Answers  


write a function that accepts an integer/char array and an search item.If the search item is there in the array return position of array and value else return -1.without using other array,without sorting,not to use more than one loop?

3 Answers   Mind Tree,


Concat two string with most overlapped substring has to removeĀ  "abcd"+ "cdef" = "abcdef

6 Answers  


Explain argument and its types.

0 Answers  


Just came across this question, felt worth sharing, so here it is I want you to make a C/C++ program that for any positive integer n will print all the positive integers from 1 up to it and then back again! Let's say n=5 I want the program to print: 1 2 3 4 5 4 3 2 1. Too easy you say? Okay then... You can ONLY USE: 1 for loop 1 printf/cout statement 2 integers( i and n) and as many operations you want. NO if statements, NO ternary operators, NO tables, NO pointers, NO functions!

1 Answers  






What are the types of operators in c?

0 Answers  


Is there any data type in c with variable size?

0 Answers  


The C language terminator is a.semicolon b.colon c.period d.exclamation mark

6 Answers   TCS,


Program to trim a given character from a string.

5 Answers   NetApp,


Write a c pgm for leap year

11 Answers   College School Exams Tests, IBM, TCS,


What are pointers? What are stacks and queues?

0 Answers   Hexaware,


In which layer of the network datastructure format change is done

0 Answers   Honeywell,


Categories