#include<stdio.h>
#include<conio.h>
main()
{
char s1[20],s2[20];
printf("enter first string");
scanf("%s",s1);
printf("enter second string");
scanf("%s",s2);
string_concatenate(&s1,&s2);
}
count_characters(char *x)
{
int i=0, count=0;
for(i=0;*(x+i)!='\0';i++)
count++;
return count;
}
string_concatenate(char *s1,char *s2)
{
int i,j;
char s3[50];
for(i=0;i
s3[i]=s1[i];
for(j=0;j
s3[i+j]=s2[j];
s3[i+j]=s2[j];
printf("%s",s3);
getch();
}
Your homework, innit?
const char *from1= "Part1";
const char *from2= "Part2";
char *to= malloc (256);
char *q= to;
while (*q++ = *from1++);
--q;
while (*q++ = *from2++);
Most high-level languages support concatenation of strings using the '+' operator. For example, in C++ you'd use the following:
#include<string>
std::string a = "Hello";
std::string b = "world";
std::string c = a + " " + b; // e.g., c = "Hello world"
import java.io.*;
class concate
{
public static void main(String args[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the string s1:");
String s1=br.readLine();
System.out.println("Enter the string s2:");
String s2=br.readLine();
String s3=s1.concat(s2);
System.out.println("The concate string is :"+s3);
}
}
String can be added to together with the plus symbol much like an int.
String a = "I like to eat";
String b = " peanut butter";
String c = a + b;
'c' will now equal "I like to eat peanut butter"
You could also use a + " peanut butter"; and not bother having a three strings
Here's one more example:
String a = "I like to eat";
a += " cheese,";
a += " bacon,";
a += " and jelly beans.";
String a will now equal "I like to eat cheese, bacon, and jelly beans." Afterwards if you use System.out.println(a);it will print that full sentence on screen.
In C and C++, to concatenate two strings without using library functions...
char* mystrcat (char* dest, char* src) {
char* savedest = dest;
while (*dest++ != '\0);
dest--;
while ((*dest++ = *src++) != '\0);
return savedest;
}
Note: Just like the library function, this routine does not verify that there is adequate space at dest - that is your responsibility.
You can use functions like strcat or sprintf, or do it manually:
q= to;
p= from1-1;
while (*++p) *q++= *p;
p= from2-1;
while (*++p) *q++= *p;
*q= '\0';
while(str1[i]!='')
{
i++;
}
while(str2[j]!='')
{
str2[j++]=str1[i++];
}
str2[j]='';
puts(str2);
a write the algorithm to concatenate two given string
It is called strcmp, part of the standard run-time library. Returns 0 if the two strings are equals, non-zero otherwise.
The String class includes two helpful methods: equals and compareTo.string1.equals(string2) will return true if the two strings contain the exact same charactersstring1.compareTo(string2) will return an int which describes the lexicographic relationship between the two strings. It will return a negative value if string1 is "less than" string2, a positive value if string1 is "greater than" string2, or zero if the two are equivalent strings.
#include<stdio.h>
Write a program using recursion which should take two values and display 1st value raised to the power of second value.
nahi malum
a write the algorithm to concatenate two given string
because when you tie a knot you join two strings together and when you get married you join the person you are marrying
write a c program to circular queue
#include main() { //please read two strings int str1 and str2// while(str1[i]!='/0' &&str2[i]!='/0') if(str1[i]!=str2[i]) flag=1; if(flag==1) printf("equal"); } #include main() { //please read two strings int str1 and str2// while(str1[i]!='/0' &&str2[i]!='/0') if(str1[i]!=str2[i]) flag=1; if(flag==1) printf("equal"); }
1*01+01*
It is called strcmp, part of the standard run-time library. Returns 0 if the two strings are equals, non-zero otherwise.
write it in 8085
how to compare two strings that take input from the user and compare it. For example: i give first string as "THE" and give second string as "HTE" then return "match" if i give first as"THE" nd second string as "EHI" then return "NOtMatch" witout using STRCMP ... please help me
The String class includes two helpful methods: equals and compareTo.string1.equals(string2) will return true if the two strings contain the exact same charactersstring1.compareTo(string2) will return an int which describes the lexicographic relationship between the two strings. It will return a negative value if string1 is "less than" string2, a positive value if string1 is "greater than" string2, or zero if the two are equivalent strings.
It was a pouch with two strings attached to it.
fish