#include,stdio.h>
main()
{
char string1[20],string2[20]
printf("enter the first string");
scanf("%s",string1);// reading the string1
printf("enter the second string");
scanf("%s", string2);// reading the the string2
printf( "the first string is %s",string1);// printing the string1
printf("the second string is %s",string2);// printing the string2
}
the problem of using scanf is that it does not take space. so we can use gets for it.
ie instead of scanf("%s",string1); we can use gets(string1); .
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 #include using std::cin;using std::cout;using std::endl;using std::string;int main(void){string str1 = "nothing here";cout str1;string str2 = "neither here";cout str2;string srt = "result here";cout
This is for RPG ILE Programming.
By using those two functions in your code.
nahi malum
#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"); }
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.
You can use so called concatenation of strings:{...string str1 = "something here";string str2 = " and something here";string newStr = str1 + str2;...}
char one [] = "A string" ;char two [] = "Different String" ;if (strcmp (one, two) == 0){puts ("The two strings are identical") ;}else{puts ("The two strings are different") ;}
#include int main (int argc, char **argv){printf ("The name of this program is %s\n", argv[0]);return 0;}There's two character-string in this program, a literal and a variable. Go find them.
Using strcpy and strcat. Or sprintf. Or strlen+memcpy. There are more than solutions.
Yes, when it is needed. YOu can use any combination of strings, so using all 6 at the same time is just as common as using one string.
program to find maximum of two numbers using pointers
#include #include using std::cin;using std::cout;using std::endl;using std::string;int main(void){string str1 = "nothing here";cout str1;string str2 = "neither here";cout str2;string srt = "result here";cout
It was a pouch with two strings attached to it.