Go Back   Armenian Knowledge Base > Technical sections > Languages, Compilers, Interpreters

Reply
 
Thread Tools

Comparing Strings
Old 11.06.2003, 00:01   #1
Дошкольник
 
Diane-'s Avatar
 
Join Date: 04 2003
Location: USA
Posts: 103
Rep Power: 0
Question Comparing Strings

Guys i have a question about comparing strings.For example

string word1;
string word2;

word1="Tremendous";
word2="Tremble";

word1<word2;

The boolean value will be false , cause computer compares each character one by one and as "b" has lesser value in ASCII than "e", it gives a false value.
So the question is , can computer stop at the first character in the string, meaning that it will compare just "T" and set the boolean value to true?
__________________
No se preocupe, sea feliz !

Last edited by Diane-; 11.06.2003 at 17:37.

Old 11.06.2003, 04:29   #2
Грустно...
 
Agregat's Avatar
 
Join Date: 08 2002
Location: Там, где всегда идут дожди
Age: 44
Posts: 21,717
Rep Power: 9
Default

1. the value 'b' is less than the value 'e' but you are true, word1 < word2 is false.

2. If computer stops after the first symbol the result will be false , because 'T' < 'T' is false ('T' <= 'T' is true).

Лучше скажите нам, что вам нужно...

Old 11.06.2003, 12:52   #3
Banned
 
DaNYer's Avatar
 
Join Date: 10 2002
Location: Brooklyn, New York
Age: 48
Posts: 3,760
Rep Power: 0
Default

1. dobav'te proverochku na dlinnu stroki (smotrya chto vam nujno... esli ugodno schitaite dlinnuiu stroku bol'shei)

2. v ostal'nix sluchayax vse pral'no. (esli dlinna ravna)

3. chestno govorya ya ne ochen' ponyal vopros....

Old 11.06.2003, 17:22   #4
Академик
 
W_z_rd's Avatar
 
Join Date: 08 2002
Location: Yerevan, Armenia
Age: 54
Posts: 4,854
Rep Power: 5
Default

Deystvitel`no, a v chem vopros/problema ??

Old 11.06.2003, 17:35   #5
Дошкольник
 
Diane-'s Avatar
 
Join Date: 04 2003
Location: USA
Posts: 103
Rep Power: 0
Default

Agregat yes u right , thats what i wanted to write, but somehow managed to write in the wrong way.
And I know that "T"<"T" will be false, thats not what i was asking.
Nam nichego ne nujno ,nujen bil otvet na etot vopros, vozmojno li ostanovit posle pervoi bukvi.
Danyer ,"dobavit proverochki" kak na angliyskom budet zvuchat?
Eto ne svyazano s kakim to imenno projectom i ya znayu chto etot privedennii mnoyu primer veren. vopros lij v tom, mojli li ostanovit computer posle pervoi bukvi, v lubom sravnenii string-ov.
Neznayu kak vam eshe obyasnit

Old 11.06.2003, 17:55   #6
Banned
 
DaNYer's Avatar
 
Join Date: 10 2002
Location: Brooklyn, New York
Age: 48
Posts: 3,760
Rep Power: 0
Default

mojno.

1. proveryai TOL'KO pervuiu bukvu (if(s1[0]==s2[0]))

2. s[i]

i nachinai s 0

ne narashivai.

chto to je samoe chto i s1[0]

----------

add a condition checking
e.g.
if ( strlen(s1) > strlen(s2)) i t.d. biblioteka string.h
Reply




Реклама:
реклама
Buy text link .

All times are GMT. The time now is 10:50.
Top

Powered by vBulletin® Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.