#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

Q. where is the below variables stored ? - volatile, static, register

3 Answers   Bosch,


What is keyword with example?

0 Answers  


union { char ch[10]; short s; }test; test.s = 0xabcd; main() { printf("%d",ch[10]); }

3 Answers  


What is the scope of local variable in c?

0 Answers  


What is the difference between near, far and huge pointers?

0 Answers  


What does 4d mean in c?

0 Answers  


What is a good data structure to use for storing lines of text?

0 Answers  


What is #pragma directive?how it is used in the program? what is its advantages and disadvantages?

2 Answers  


What is sizeof in c?

0 Answers  


There is a mobile keypad with numbers 0-9 and alphabets on it. take input of 7 keys and then form a word from the alphabets present on those keys.

0 Answers  


what is difference between C and C++

4 Answers  


without using arithmatic operator convert an intger variable x into x+1

3 Answers  


Categories