hex in char arrays :S

This is a discussion on hex in char arrays :S within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by Elyubarov I did not make the server so i cant change what packets it accepts, I am ...

  1. #31
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    Quote Originally Posted by Elyubarov
    I did not make the server so i cant change what packets it accepts, I am not sending this in hex because i need the length i would just use the strlen() operator. I am sending it in hex because its some pretty weird ascii chars and i dont think vc++ would accept them, can i do it in a string literal with ascii chars(that are weird)?
    if you're sending something to a server you can be sure the server is expecting you to tell it how many bytes you are going to be sending it. otherwise it won't know when to quit accepting data from you. read the server documentation to find out the format in which you send it data.
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  2. #32
    Registered User
    Join Date
    Dec 2004
    Posts
    38
    there is no documentation, I making a client for a program, I packet sniffed. Anyways, the string was always there its just when i put it in a MessageBox() the MessageBox didnt read past the NULL(0x00), but when i sent it through a socket it was ok, i just could not use strlen(), one more question: does sprintf() stop at the NULL as well, because i am having trouble with it.

  3. #33
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >does sprintf() stop at the NULL as well
    Yes. Most functions that expect a C-style string will use the null character as a sentinel. If it's not there then you risk undefined behavior.
    My best code is written with the delete key.

  4. #34
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    You can work with your strings manually, char by char. It requires a lot of loops, etc.. but once you've done a couple of simple operations it's really quite easy. the send() function in Winsock (and I imagine the same is true in other APIs), a buffer is sent as a parameter, with an integer telling the length - that's the type of string we've been telling you to use for quite some time now. Depending on where you get this string from originally, if you use this type of string all along, strlen() is probably not necessary.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 04:06 PM
  2. returning char arrays!!!!
    By bobthebullet990 in forum C Programming
    Replies: 2
    Last Post: 03-30-2006, 07:05 AM
  3. Replies: 11
    Last Post: 03-24-2006, 11:26 AM
  4. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 11:28 PM
  5. comparing fields in a text file
    By darfader in forum C Programming
    Replies: 9
    Last Post: 08-22-2003, 09:21 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21