Hello guys,

I have this structure with another double pointer structure inside that I need to pass through named pipes with the function WriteFile from WinAPI.

typedef struct Labyrinth{
    Cell **board;
    int currentLevel;
} Labyrinth;

typedef struct Cell{    
    BOOL wall;
    BOOL player;
    BOOL object;
    BOOL enemy;
    BOOL labyrinthExit;
    int objectType;
    int objectQuantity;
} Cell;

I am passing it like this


            fSuccess = WriteFile(
                hPipe,        // handle to pipe 
                &message,     // buffer to write from 
                sizeof(Message), // number of bytes to write 
                &cbWritten,   // number of bytes written 
                NULL);        // not overlapped I/O 

And I'm writing the board like this

DWORD GenerateDefaultMap(Labyrinth *labyrinth){
    int i = 0, j = 0;

    labyrinth->board = (Cell **) malloc(MIN_SIZE * sizeof(Cell *));
    for (i = 0; i < MIN_SIZE; ++i)
        labyrinth->board[i] = (Cell *) malloc(MIN_SIZE * sizeof(Cell));

    for (i = 0; i < MIN_SIZE; i++){
        for (j = 0; j < MIN_SIZE; j++){
            if (i == 0 || i == (MIN_SIZE - 1) || j == 0 || j == (MIN_SIZE - 1))
                labyrinth->board[i][j].wall = TRUE;
                labyrinth->board[i][j].wall = FALSE;

When I receive it on the client side I have nothing but garbage. Could you guys point me in the right direction?

1 Year
Discussion Span
Last Post by rproffitt

This looks incorrect from the beginning. Pointers point to memory which is memory in your app and machine. Passing pointers to another PC would be almost meaningless 99% of the time.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.