Thread: C and Winsock problem

  1. #1
    Registered User
    Join Date
    May 2015
    Posts
    5

    Question C and Winsock problem

    I'm new in Winsock, and I have a problem with recv().

    With this code output is only:
    [ ] Downloaded: L
    Code:
    char message[200];
    char converter;
    char MSG;
    while(1 == 1){
        MSG = recv(s,message,sizeof(message),0);
        converter = message;
        printf("\n\t[ ] Downloaded: %c",converter);
    }
    If I change %c to %s program will crash.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Code:
    char message[200];
    int MSG;
    while(1){
        MSG = recv(s,message,sizeof(message),0);
        if(MSG > 0)
            printf("\n\t[ ] Downloaded: %*.*s",MSG,MSG,message);
    }
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Winsock problem
    By Wolf` in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2010, 04:55 PM
  2. Winsock Problem
    By Noxir in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2004, 10:50 AM
  3. Winsock problem
    By Rare177 in forum Windows Programming
    Replies: 0
    Last Post: 07-15-2004, 01:48 PM
  4. winsock problem
    By xlnk in forum C++ Programming
    Replies: 3
    Last Post: 12-07-2002, 04:32 PM
  5. WinSock Problem
    By loobian in forum C++ Programming
    Replies: 1
    Last Post: 02-09-2002, 11:25 AM