Thread: send() characters from integers

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    11

    send() characters from integers

    If i use the following statement:
    Code:
    printf("%c",number);
    the ascii correspondent to 'number' will be printed, how can i do the same with the send command?

    this is an example of the send() command:
    Code:
    send(socket,character,1,0);
    but for this, i cannot convert the variable type when i send it...

    is there a way to send variables using the '%c', '%d' etc. constants?
    Last edited by joecaveman; 05-17-2005 at 07:08 PM. Reason: make title more descriptive

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Code:
    send(Socket, &Charactor, 1, 0);
    Charactor should be of type char or another type that is one byte in size. Once you've received it you can use printf to display it as a char or number.
    [edit]If it must send a string you can use printf and then send the output string with send
    Code:
    send(Socket, str, strlen(str)+1, 0);
    [/edit]
    Last edited by Quantum1024; 05-17-2005 at 07:26 PM.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    11
    thanks, problem solved

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 06:55 PM
  2. sending n no of char data uning send() function,
    By thebrighter in forum Windows Programming
    Replies: 1
    Last Post: 08-22-2007, 12:26 PM
  3. send zip file via socket
    By WaterNut in forum C Programming
    Replies: 11
    Last Post: 05-24-2005, 11:49 AM
  4. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  5. Characters in a txt file.
    By tay_highfield in forum C Programming
    Replies: 3
    Last Post: 01-31-2003, 09:19 AM