anyone know a good way for doing this conversion?
for example, take the char array holding ascii charcters “ABC”, the int conversion i’m looking for would change those characters to a single int with value 656667.
any help would be very much appreciated.
edit
really appreciate the replies. as someone noted i did say char array, and specifically this is a byte array, so there could be multiple ‘\0’ or NULL elements followed by additional ascii’s. using methods like strlen, etc will cause problems. thanks again for the current input.
Most of the time, one got to look at the actual problem.
Parsing a packet protocol may or may not be easy, depending on the specification, but you can usually do better than throwing it all in a string…
If you don’t know about them, look up
Google Protocol Buffer, they can’t be used as is, but the idea is there.Net advantage ? You now have structured data. Of course there might be some endianness issue going on with the
memcpy… you’ll have to check for it.Now, I don’t know what your
mDatais supposed to be, but of course it would be better if it was structured too.Using a simple
intto store what does not look like anintat all, really is a bad idea I think… unless it was anintto begin with of course.