Registers used: ax,ds,si,di,cl
flags affected: zf,cf
program:
assume cs:code,ds:data
code segment
mov ax,data
mov ds,ax
mov si,offset str1
mov di,offset str2
mov cl,count
cld
rep cmpsb
hlt
code ends
data segment
str1 db 04h,05h,07h,08h
count equ 04h
org 0010h
str2 db 04h,06h,07h,09h
data ends
end
result:
input: str1 (ds:0000h) = 04h,05h,07h,08h
str2 (ds:0010h) = 04h,06h,07h,09h
There are two different types of equality for Strings - object equality (==) and comparative (compareTo(), equals()). Object equality compares the memory addresses of two Strings, which is probably not what you are looking for. To test for equality, you can use String's equals() method.
Example: "abc".equals("abc"); //true
#include <stdio.h> #include <string.h> int main() { char *str1 = "sample", *str2 = "sample"; if(strcmp(str1,str2)==0) printf("strings are equal"); retrun 0; }
in java, two strings can be compared .but not by using the pointers because there is no existence of pointeres in java.
pagalo hamian khud nahi ata:p
a write the algorithm to concatenate two given string
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.
write a program in C that prompts the user with the following lines: a) Add two integers c) Compare two integers for the larger t) Test an integers for odd or even q) Quit
It is called strcmp, part of the standard run-time library. Returns 0 if the two strings are equals, non-zero otherwise.
strcmp is used to compare two strings. If the return value is zero, the two strings are the same. If the return value is less than 0, then the first string is less than the second string, otherwise the first string is greater than the second string. Strings are compared lexicographically, character by character.
nahi malum
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
#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"); }
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") ;}
a write the algorithm to concatenate two given string
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 don't need a program to compare strings since std::string already provides support for all the comparison operators (<, <=, >, >=, == and !=). To roll your own you must first create a string class and then provide operator overloads for the comparison operators. To compare strings, start at the first character in each string and compare. So long as they remain equal, move onto the next character. The comparison ends as soon as any character differs. You need only compare these two characters to decide which string is the lesser. To perform a case insensitive comparison, copy the two characters and convert the copies to lower case (or upper case, it doesn't matter). Then compare the copies. Do this for each character as you compare them rather than converting the entire string.
write a program in C that prompts the user with the following lines: a) Add two integers c) Compare two integers for the larger t) Test an integers for odd or even q) Quit
write a c program to circular queue
what is the form you would use the word curiously to compare two things
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.