Raised This Month: $51 Target: $400
 12% 

[help] getting 1º char in text


Post New Thread Reply   
 
Thread Tools Display Modes
Keeper
Senior Member
Join Date: Nov 2006
Old 05-01-2007 , 15:13   Re: [help] getting 1º char in text
Reply With Quote #21

Meaning I bet he's trying to compare the result of text[0] to a const char*.
Keeper is offline
sn4k3
Senior Member
Join Date: Nov 2005
Old 05-01-2007 , 15:51   Re: [help] getting 1º char in text
Reply With Quote #22

Quote:
Originally Posted by Keeper View Post
Meaning I bet he's trying to compare the result of text[0] to a const char*.
no i using yours exemples

with char *

Code:
char *sText = "Hey";
char *sFirstLetter = ( Q_strlen(sText) != 0 ? sText[0] : "" );
Or

Code:
char* s = "Hey";
char* f = (strlen(s) != 0 ? s[0] : "");
= errors in compile for me
sn4k3 is offline
Send a message via MSN to sn4k3
Keeper
Senior Member
Join Date: Nov 2006
Old 05-01-2007 , 16:00   Re: [help] getting 1º char in text
Reply With Quote #23

Try this then:

const char* text = "#text";
if (text[0] == '#') {
// do your code here
}

or:

char *sText = "Hey";
char sFirstLetter = ( strlen(sText) != 0 ? sText[0] : 0 );

Last edited by Keeper; 05-01-2007 at 16:18.
Keeper is offline
sn4k3
Senior Member
Join Date: Nov 2005
Old 05-02-2007 , 08:11   Re: [help] getting 1º char in text
Reply With Quote #24

Quote:
Originally Posted by Keeper View Post
Try this then:

const char* text = "#text";
if (text[0] == '#') {
// do your code here
}

or:

char *sText = "Hey";
char sFirstLetter = ( strlen(sText) != 0 ? sText[0] : 0 );
ty i gona try

i have used last exemple i think and works in compile but crash on use but i will try
sn4k3 is offline
Send a message via MSN to sn4k3
showdax
Senior Member
Join Date: Dec 2004
Old 05-02-2007 , 14:18   Re: [help] getting 1º char in text
Reply With Quote #25

Quote:
Originally Posted by Keeper View Post
char *sText = "Hey";
char sFirstLetter = ( strlen(sText) != 0 ? sText[0] : 0 );
Don't do this. I just went over how that's all completely unnecessary!
showdax is offline
Send a message via MSN to showdax
Keeper
Senior Member
Join Date: Nov 2006
Old 05-02-2007 , 15:20   Re: [help] getting 1º char in text
Reply With Quote #26

I understand what you said, but I was posting how the given example could be made to work.

using "char sFirstLetter = sText[0]" would be fine too...
Keeper is offline
sn4k3
Senior Member
Join Date: Nov 2005
Old 05-03-2007 , 08:16   Re: [help] getting 1º char in text
Reply With Quote #27

Quote:
Originally Posted by Keeper View Post
I understand what you said, but I was posting how the given example could be made to work.

using "char sFirstLetter = sText[0]" would be fine too...
ty yours exemples works
sn4k3 is offline
Send a message via MSN to sn4k3
Reply



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:48.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode