AKB Forums

Go Back   AKB Forums > Technical sections > Languages, Compilers and Interpreters
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Languages, Compilers and Interpreters C,C++,C#,.NET,Java,PHP,Perl,SQL and more

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old Jun 11, 2003, 00:01   #1
Дошкольник
 
Diane-'s Avatar
 
Join Date: Apr 2003
Location: USA
Posts: 103
Rep Power: 6
Reputation: 10
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- : Jun 11, 2003 at 17:37.
Diane- is offline   Reply With Quote Quote selected
Old Jun 11, 2003, 04:29   #2
Грустно...
 
Agregat's Avatar
 
Join Date: Aug 2002
Location: Там, где всегда идут дожди
Posts: 21,545
Rep Power: 11
Reputation: 169
Send a message via ICQ to Agregat Send a message via MSN to Agregat
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).

Лучше скажите нам, что вам нужно...
__________________
http://аvitya.livejournal.com
Хотели, как лучше, а получилось даже хуже...
Лозунг шахматиста: На каждый шах - ответим матом!
Agregat is offline   Reply With Quote Quote selected
Old Jun 11, 2003, 12:52   #3
Banned
 
DaNYer's Avatar
 
Join Date: Oct 2002
Location: Brooklyn, New York
Posts: 3,760
Rep Power: 0
Reputation: 10
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....
DaNYer is offline   Reply With Quote Quote selected
Old Jun 11, 2003, 17:22   #4
Академик
 
Join Date: Aug 2002
Location: Yerevan, Armenia
Posts: 4,455
Rep Power: 7
Reputation: 45
Send a message via ICQ to W_z_rd
Deystvitel`no, a v chem vopros/problema ??
__________________
Stuck between heaven and hell; dunno where to go...
W_z_rd is offline   Reply With Quote Quote selected
Old Jun 11, 2003, 17:35   #5
Дошкольник
 
Diane-'s Avatar
 
Join Date: Apr 2003
Location: USA
Posts: 103
Rep Power: 6
Reputation: 10
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
__________________
No se preocupe, sea feliz !
Diane- is offline   Reply With Quote Quote selected
Old Jun 11, 2003, 17:55   #6
Banned
 
DaNYer's Avatar
 
Join Date: Oct 2002
Location: Brooklyn, New York
Posts: 3,760
Rep Power: 0
Reputation: 10
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
DaNYer is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:51.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link