| View previous topic :: View next topic |
| Author |
Message |
Cx Master Cheater
Reputation: 0
Joined: 27 Jul 2007 Posts: 367
|
Posted: Mon Feb 25, 2008 10:05 pm Post subject: String -> Char/SmallInt? |
|
|
Is there any way to convert a string to a char/small integer?
Like atoi or strtoul, but for char/smallint.
If not, is there some type of casting to be done?
_________________
armed with this small butterfly net
i will face the world alone
& never be lonely. |
|
| Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Tue Feb 26, 2008 6:02 am Post subject: |
|
|
uhhh, what language, kind of important info, duh!
_________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Tue Feb 26, 2008 7:00 am Post subject: |
|
|
No, because the string might contain more than 1 char.
If you want, you can check the first character, string[0] or check if the string length is 1, but in this case its easier to just get a single character instead of a string.
What exacly are you trying to do?
|
|
| Back to top |
|
 |
Renkokuken GO Moderator
Reputation: 4
Joined: 22 Oct 2006 Posts: 3249
|
Posted: Tue Feb 26, 2008 7:40 am Post subject: |
|
|
| Snootae wrote: | | uhhh, what language, kind of important info, duh! | It'd obvious if you knew what atoi and strtoul were.
|
|
| Back to top |
|
 |
Cx Master Cheater
Reputation: 0
Joined: 27 Jul 2007 Posts: 367
|
Posted: Tue Feb 26, 2008 9:02 pm Post subject: |
|
|
| Symbol wrote: | No, because the string might contain more than 1 char.
If you want, you can check the first character, string[0] or check if the string length is 1, but in this case its easier to just get a single character instead of a string.
What exacly are you trying to do? |
So? What happens if there is more than an int in your string for atoi? It doesn't matter. I can check return values or use a loop, etc.
And you don't get what I mean-- I don't mean char as in a letter. I mean the numeric data type char (because an unsigned char is kinda what we know as a byte).
Like, converting the string "0xFF" to the unsigned char value 0xFF.
_________________
armed with this small butterfly net
i will face the world alone
& never be lonely. |
|
| Back to top |
|
 |
Cx Master Cheater
Reputation: 0
Joined: 27 Jul 2007 Posts: 367
|
Posted: Wed Feb 27, 2008 2:36 am Post subject: |
|
|
Thanks.
_________________
armed with this small butterfly net
i will face the world alone
& never be lonely. |
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Wed Feb 27, 2008 4:59 am Post subject: |
|
|
| Snootae wrote: | | uhhh, what language, kind of important info, duh! |
lol, no it's not.
you can give general example and he can understand the point.
|
|
| Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Wed Feb 27, 2008 5:01 am Post subject: |
|
|
| Quote: | It'd obvious if you knew what atoi and strtoul were
|
ahh, fair enough, just though it might help someone else who knew
_________________
|
|
| Back to top |
|
 |
|