• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved [C++] how to convert a string to uint32_t

filhodaputa

New Member
Joined
Apr 29, 2010
Messages
4
Reaction score
0
Ok, I need this request, if someone knows this please post...
 
Last edited by a moderator:
no have other func??? look
i get a storage value from a player.... i need use the storage to set the life a monster... changeHealth(int32_t)...
atoi <<< no return error but crashing my console...


EDIT: i fix this! tanks, i making a quest with monsters "not easy" for high level players, tanks for help!!! rep+ for u Scarlet Ayleid :))
 
Last edited:
You can use Encoding.ASCII.GetBytes to convert your string to a byte array with ASCII encoding (each character taking one byte). Then, call BitConverter.ToUInt32 to convert that byte array to a uint. However, a uint is only 4 bytes, so you'll need to do some partitioning of your array first.
 
PHP:
	std::string example = "69";
	uint32_t value = fromString<uint32_t>(example);
 
You can use Encoding.ASCII.GetBytes to convert your string to a byte array with ASCII encoding (each character taking one byte). Then, call BitConverter.ToUInt32 to convert that byte array to a uint. However, a uint is only 4 bytes, so you'll need to do some partitioning of your array first.

Hi Nevermore, TFS is written in C++.

@sn4ake:
Instead of calling that bloat templated function he can simply do that by:
Code:
uint32_t value = atoi(something.c_str());
 
Back
Top