#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 are the rules for identifiers in c?
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?
Concat two string with most overlapped substring has to removeĀ "abcd"+ "cdef" = "abcdef
Explain argument and its types.
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!
What are the types of operators in c?
Is there any data type in c with variable size?
The C language terminator is a.semicolon b.colon c.period d.exclamation mark
Program to trim a given character from a string.
Write a c pgm for leap year
11 Answers College School Exams Tests, IBM, TCS,
What are pointers? What are stacks and queues?
In which layer of the network datastructure format change is done