Results 1 to 11 of 11
  1. Default Question about C programming

    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"?

  2. Default

    unsigned char* unpackedZlibBlock = getUnpackedZlibBlock();
    unsigned char* zlibBlockPos = unpackedZlibBlock;
    unsigned int numberOfChinchillas = *((unsigned int *) (zlibBlockPos));
    zlibBlockPos += 4;

    You can just cast the unsigned char pointer to an unsigned int (or whatever) pointer.

  3. Default

    Perfect. Just what I needed. Thank you very much.

  4. Default

    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?

  5. Flatpanel TV
    IGN: Leonage
    Server: Scania
    Level: 128
    Job: Arch Mage
    Guild: LouisVuitton
    Alliance: .


    O_o, english plox.
    you guys use numbers to much. And sometimes letters.

  6. Default

    ^ There's only one number posted in this thread, lol.
    This isn't a thread about English

  7. Default

    Isn't the whole point of this thread to discuss a different language?

  8. Default

    Nevermind. I just figured it out.

  9. Default

    So you ask for english, then say that they sometimes use letters too much? Isn't english made up of letters?

    Seriously though, if you read the thread title it says "Programming". SURELY you would have at least a small idea what that is, and if not you probably could have realised by seeing this thread/ other threads with programming in them.

    And the only number I can see is "zlibBlockPos += 4 o_o
    Last edited by Heidi; 2009-08-14 at 10:31 PM.

  10. Default

    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.

  11. Default

    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



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts