Test Mushroom
Posts: 10,045
Threads: 1,506
Joined: 2008-06
Gender: Male
Sexual Orientation: Straight
Country Flag: usa
IGN: GuavaCowboy
Server: Zenith
Level: 10x
Job: Jett
Guild: L>
I have an "unsigned char* unpackedZlibBlock;" string, but I want to be able to read values from that string (ints, doubles, floats). So let's say that the first four bytes of this string is supposed to be interpreted as an integer. What would be the best way to fetch those four bytes from the string? "strncpy"? "memcpy"?
Test Mushroom
Posts: 10,045
Threads: 1,506
Joined: 2008-06
Gender: Male
Sexual Orientation: Straight
Country Flag: usa
IGN: GuavaCowboy
Server: Zenith
Level: 10x
Job: Jett
Guild: L>
Perfect. Just what I needed. Thank you very much.
Test Mushroom
Posts: 10,045
Threads: 1,506
Joined: 2008-06
Gender: Male
Sexual Orientation: Straight
Country Flag: usa
IGN: GuavaCowboy
Server: Zenith
Level: 10x
Job: Jett
Guild: L>
I have another question and I didn't want to bother making a new topic for it:
if I have 'a' assigned to "char foo", what command can I give such that "char* bar" equals "aaaaaa"? How do I copy strings like that without using a loop?
Posting Freak
Posts: 1,370
Threads: 37
Joined: 2008-07
O_o, english plox.
you guys use numbers to much. And sometimes letters.
Test Mushroom
Posts: 10,045
Threads: 1,506
Joined: 2008-06
Gender: Male
Sexual Orientation: Straight
Country Flag: usa
IGN: GuavaCowboy
Server: Zenith
Level: 10x
Job: Jett
Guild: L>
Nevermind. I just figured it out.
Posting Freak
Posts: 7,488
Threads: 76
Joined: 2008-07
Gender: Male
Sexual Orientation: Straight
Country Flag: North_Carolina
IGN: I don't play MS
lol it's a C programming thread, if you can't tell a char* from an operator just don't bother posting.
I'm interested in what the solution was to your second question, Fiel.
Test Mushroom
Posts: 10,045
Threads: 1,506
Joined: 2008-06
Gender: Male
Sexual Orientation: Straight
Country Flag: usa
IGN: GuavaCowboy
Server: Zenith
Level: 10x
Job: Jett
Guild: L>
Well, it's a cheating way of doing it.
Since I'll eventually be using the char array to write to a file, just do this...
fwrite(myCharArray, 1, 7, MyFile);
fseek(MyFile, -7, SEEK_CUR);
//define a new char type, then fread it