Armenian Knowledge Base  

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

Reply
 
LinkBack Thread Tools
Old 11.06.2003, 01:01   #1
Дошкольник
 
Diane-'s Avatar
 
Join Date: 04 2003
Location: USA
Posts: 103
Downloads: 0
Uploads: 0
Reputation: 0 | 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 18:37.
Reply With Quote
Old 11.06.2003, 05:29   #2
Грустно...
 
Agregat's Avatar
 
Join Date: 08 2002
Location: Там, где всегда идут дожди
Age: 35
Posts: 21,717
Downloads: 2
Uploads: 0
Reputation: 250 | 7
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).

Лучше скажите нам, что вам нужно...
Reply With Quote
Old 11.06.2003, 13:52   #3
Banned
 
DaNYer's Avatar
 
Join Date: 10 2002
Location: Brooklyn, New York
Age: 39
Posts: 3,760
Downloads: 0
Uploads: 0
Reputation: 0 | 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....
Reply With Quote
Old 11.06.2003, 18:22   #4
Академик
 
W_z_rd's Avatar
 
Join Date: 08 2002
Location: Yerevan, Armenia
Age: 45
Posts: 4,854
Downloads: 1
Uploads: 0
Reputation: 225 | 3
Default

Deystvitel`no, a v chem vopros/problema ??
Reply With Quote
Old 11.06.2003, 18:35   #5
Дошкольник
 
Diane-'s Avatar
 
Join Date: 04 2003
Location: USA
Posts: 103
Downloads: 0
Uploads: 0
Reputation: 0 | 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
Reply With Quote
Old 11.06.2003, 18:55   #6
Banned
 
DaNYer's Avatar
 
Join Date: 10 2002
Location: Brooklyn, New York
Age: 39
Posts: 3,760
Downloads: 0
Uploads: 0
Reputation: 0 | 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 With Quote
Sponsored Links
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 04:01.


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