Thread: hex in char arrays :S

  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,897
    >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
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    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.

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, 03: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, 10:28 PM
  5. comparing fields in a text file
    By darfader in forum C Programming
    Replies: 9
    Last Post: 08-22-2003, 08:21 AM