Yeronox's Profile User Rating: -----

Reputation: 2 Apprentice
Group:
Active Members
Active Posts:
102 (0.11 per day)
Joined:
12-March 12
Profile Views:
2,148
Last Active:
User is offline Aug 07 2014 11:50 PM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0
Icon   Yeronox is learning PHP!

Posts I've Made

  1. In Topic: Reverse string problem

    Posted 7 Aug 2014

    View PosttlhIn`toq, on 07 August 2014 - 02:15 PM, said:

    You do see that line 24 is console.writeLINE not console.write - right?
    I would guess it writes every letter on its own line.
    So its not adding a "\n" to your result, its just displaying it one letter per line.

    Fixed. That was the problem.
    Thank you sooo much!
    return 1;
  2. In Topic: Reverse string problem

    Posted 7 Aug 2014

    View Postmodi123_1, on 07 August 2014 - 01:34 PM, said:

    37	                goto input;
    

    Any particular reason you are using a 'goto' instead of a properly formatted loop?

    I just wanted to try it again to see if it worked, so I just added a 'goto'; but there's even no need to add that check (the exercise is just to reverse the string)
  3. In Topic: UDP Server: weird connections

    Posted 24 Apr 2014

    Is it OK if I use
    inet_addr("192.168.1.100");
    
    ?
  4. In Topic: UDP Server: weird connections

    Posted 24 Apr 2014

    Well, I'm using Code::Blocks and it's building and opening it.. I've added "-lws2_32" to the linker tab too.
  5. In Topic: UDP Server: weird connections

    Posted 24 Apr 2014

    #include <stdio.h>
    #include <stdlib.h>
    #include <winsock2.h>
    
    #define PORT        7890
    #define RECV_BUFFER 100
    
    int main()
    {
        WSADATA wsaData;
        SOCKET RecvSocket;
        SOCKET SenderSocket;
        SOCKADDR_IN RecvAddr;
        SOCKADDR_IN SenderAddr;
        int SenderAddrLen = sizeof(SenderAddr);
        int SenderSockLen = sizeof(SenderSocket);
    
        WSAStartup(MAKEWORD(2,2), &wsaData);
        if ((RecvSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == SOCKET_ERROR)
            exit(1);
    
        RecvAddr.sin_addr.s_addr = htonl("192.168.1.101");
        RecvAddr.sin_family = AF_INET;
        RecvAddr.sin_port = htons(PORT);
    
        if(bind(RecvSocket, (SOCKADDR*)&SenderAddr, SenderAddrLen) < 0)
            exit(2);
    
        char buffer[RECV_BUFFER];
        int i, recv_len;
        while (1)
        {
            memset(buffer,'\0', RECV_BUFFER);
            if((recv_len = recvfrom(RecvSocket, &buffer, RECV_BUFFER, 0, (SOCKADDR*)&SenderAddr, &SenderAddrLen)) < 0)
                exit(3);
            for(i = 0; i < RECV_BUFFER; i++)
                printf("%c", buffer[i]);
            printf("\nReceived from %s:%d\n", inet_ntoa(SenderAddr.sin_addr), ntohs(SenderAddr.sin_port));
            sendto(SenderSocket, "\nI've got your data!\n", sizeof("I've got your data!")+2, 0, (SOCKADDR*)&SenderAddr, sizeof(SenderAddr));
        }
        closesocket(RecvSocket);
        WSACleanup();
    }
    
    

    Same issues
    EDIT: sorry, I get this error in the build log:
    Process terminated with status 2 (0 minute(s), 1 second(s))

    What's wrong? I think the bind() should work..

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Programming Languages:
C++, PHP

Contact Information

E-mail:
Private

Friends

Comments

Yeronox has no profile comments yet. Why not say hello?