code for concatination of 2 strings with out using library
functions?
Answers were Sorted based on User's Feedback
Answer / kiruthikau
[code]
#include<stdio.h>
#include<string.h>
main()
{
char one[]="hai";
char two[]=" hello";
int len1=strlen(one);
int len2=strlen(two);
char res[len1+len2];
int i,j;
for(i=0;i<len1;i++)
res[i]=one[i];
for(j=0;j<len2,i<len1+len2;i++,j++)
res[i]=two[j];
res[i]='\0';
printf("res:%s\n",res);
}
[/code]
If you don't want to use strlen() function also ,try the
following code.
[code]
#include<stdio.h>
#include<string.h>
main()
{
char one[]="hai";
char two[]=" hello";
int len1=0;
int len2=0;
int i=0;
int j;
while(one[i++]!='\0')
len1++;
i=0;
while(two[i++]!='\0')
len2++;
char res[len1+len2];
for(i=0;i<len1;i++)
res[i]=one[i];
for(j=0;j<len2,i<len1+len2;i++,j++)
res[i]=two[j];
res[i]='\0';
printf("res:%s\n",res);
}
[/code]
Is This Answer Correct ? | 5 Yes | 1 No |
#include<stdio.h>
#include<conio.h>
void strrcat(char *,char *);
void main()
{
char a[50],b[50];
int i;
clrscr();
printf("enter the string 1 :");
gets(a);
printf("enter the string 2 :");
gets(b);
strrcat(a,b);
gets(a);
getch();
}
void strrcat(char *a , char *b)
{
for(int i=0;*a!='\0';i++,a++);
for(int j=0;*b!='\0';j++,i++,b++,a++)
*a=*b;
*a='\0';
}
thank u :)
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / chavidi
void main()
{
char a[20],b[20];
int i,j,k;
gets(a);
gets(b);
i=strlen(a);
k=i+strlen(b);
j=0;
while(i<=k)
{
a[i]=b[j];
i++;
j++;
}
printf("Resultant String is %d :",a);
}
Is This Answer Correct ? | 0 Yes | 0 No |
What is null pointer constant?
how to set Nth bit of variable by using MACRO
main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }
In CMM or CMMI certified organizations,we assess only the standard software processes of the organization. We do not assess the organizations other functional departments like HR or Admin. Then how can we certify the entire organization as CMM level company?? We have assessed only software related activities. Right. There is no relation with other departments like Accounts, HR or Admin. Then how can we claim that the whole company is a CMM certified company?
Fifty minutes ago if it was four times as many mints past 3 o clock. how many minutes is it to six o'clock n how....?????
What are the 5 types of organizational structures?
How do we select the big element or any other operation from array which is read dynamically. user need to give the elements only no need to mention the size.
where can function pointers be used?
How can you allocate arrays or structures bigger than 64K?
Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings
1) write a program to generate 1st n fibonacci prime numbers using Nested if 2) write a program to generate twin prime numbers from m to n using nested if 3) write a program to check whether a given integer is a strong number or not using nested if 4) Write a program to generate prime factors of a given integer using nested if 5)write a program to generate prime numbers from m to n using nested if 6)write a program to generate perfect numbers from m to n using nested if 7)write a program to generate the pallindromes from m to n using neste if 8)write a program to generate armstrong numbers from m to n using nested if 9)write a program to generate strong numbers from m to n using nested if
Write a program to check armstrong number in c?