#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
In c programming language, how many parameters can be passed to a function ?
What are enums in c?
Here is a good puzzle: how do you write a program which produces its own source code as output?
Why we use stdio h in c?
`write a program to display the recomended action depends on a color of trafic light using nested if statments
List the difference between a While & Do While loops?
write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.
How are variables declared in c?
Is c weakly typed?
Describe the modifier in c?
Is there a built-in function in C that can be used for sorting data?
Which is better malloc or calloc?
what is the syallabus of computer science students in group- 1?
Which is best linux os?
A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?