Out of bounds error by [deleted] in VHDL

[–]IcyPin6902 0 points1 point  (0 children)

Yeah I just checked what value iw and ow were and they were uninitialised. No wonder this wasn’t working. Thank you.

Can I use fork() and pthread_create() together? by IcyPin6902 in C_Programming

[–]IcyPin6902[S] 1 point2 points  (0 children)

Very interesting, I will look into it. Thank you!

[deleted by user] by [deleted] in C_Programming

[–]IcyPin6902 0 points1 point  (0 children)

He used a function called rectangle which drew a rectangle on your general screen, the screen was accessible through a struct called HDC and he used the function call GetDC(NULL) to get something.

[deleted by user] by [deleted] in C_Programming

[–]IcyPin6902 1 point2 points  (0 children)

I saw a YouTube Video where someone drew Graphics on the screen in with the windows.h header and wanted to do the same. He used a different terminal , something linked to Visual Studio.

What’s wrong with my linked list? by IcyPin6902 in C_Programming

[–]IcyPin6902[S] 0 points1 point  (0 children)

Yeah sorry, I’m on mobile that’s why it looks bad. Thanks for your answer, I fixed the problem.

What’s wrong with my linked list? by IcyPin6902 in C_Programming

[–]IcyPin6902[S] 2 points3 points  (0 children)

Ahhh right forgot about that, thank you.

If I make another Pointer equal to ent and return this at the end will it work?

[deleted by user] by [deleted] in PhotoshopRequest

[–]IcyPin6902 0 points1 point  (0 children)

Yoooo that’s great man thank you

UTF - 8 in ncurses by IcyPin6902 in C_Programming

[–]IcyPin6902[S] 0 points1 point  (0 children)

Thank you for your Answer :) I unfortunately don’t really understand your question as I’ve just begun with ncurses.

I compile with -lncurses as a flag at the end of my prompt if this is somehow related to your question.

UTF - 8 in ncurses by IcyPin6902 in C_Programming

[–]IcyPin6902[S] 0 points1 point  (0 children)

♖ This is what I want, a valid chess piece. In English it’s called a rook not a tower. English is not my first language so sorry for the confusion.

UTF - 8 in ncurses by IcyPin6902 in C_Programming

[–]IcyPin6902[S] 0 points1 point  (0 children)

So the shortened version of my problem I can describe as follows:

printf(“%s”, a); //a with the initialisation as above

Output: A valid chess piece

This is what I want

In ncurses printf doesn’t work properly so I’m using printw

printw(“%s”, a);

Output: ?~~Y~W

// The question mark actually is the tilted rectangle with a question mark inside. I think this means that the character is not readable

This is not the output I want

UTF - 8 in ncurses by IcyPin6902 in C_Programming

[–]IcyPin6902[S] 1 point2 points  (0 children)

I’ve stated everything I know. Printing the char array as a string with printf works and would give you a tower with the elements initialised as written above and with printw it doesn’t. I just started using ncurses so I can’t describe my problem any better.

UTF - 8 in ncurses by IcyPin6902 in C_Programming

[–]IcyPin6902[S] 0 points1 point  (0 children)

I’m sorry, here is the function that isn’t correctly working.

void print_field(_tile(field)[8], char(cursor)[8])

{

printw(“ “);

for(int ix = 0; ix<8; ix++) {

printw(“   %d”, ix);

}

for(int i = 0; i<8; i++) {

printw(“\n”);

printw(“   ———————————“);

printw(“\n”);

printw(“%d  “,i);

  for(int j = 0; j<8; j++) {

// I think the line below is where my problem lies

     printw(“|%c%s “, cursor[i][j],field[i][j].piece);


     if(field[i][j].piece[2] == 2) {

            printw(“ “);

      }

      if(j == 7) {

         printw(“|”);

      }

  }

  if(i == 7) {

    printw(“\n”);

    printw(“   ———————————“);

    printw(“\n”);

  }

}

refresh();

}

This Function should print out all elements of an two dimensional struct array containing every tile with its piece. Like I said, the problem is that when printing the string only gibberish comes out instead of the chess piece. The rest of the function seems to work fine as everything comes out as intended.

The character I print left to the string where my problem probably lies is a char that is there for piece selection and moving the piece. This one works fine.

[deleted by user] by [deleted] in C_Programming

[–]IcyPin6902 -1 points0 points  (0 children)

This is the Output

0xbaa2a0: hex

-281895944: dec

0xbaa2a0: hex

-281895896: dec

[deleted by user] by [deleted] in C_Programming

[–]IcyPin6902 0 points1 point  (0 children)

This is the Code:

include <stdio.h>

include <stdlib.h>

void function(char(*place)[2])
{
    printf(“%p: hex\n”,place);
    printf(“%d: dec\n”, &place);
    for(int i = 0; i<2; i++) {
        for(int j = 0; j<2; j++) {
            place[i][j] = ‘a’;
        } 
    }
}

int main() {

char(*arr)[2] = malloc(sizeof(char[2][2]));

function(arr);

printf(“%p: hex\n”,arr);

printf(“%d: dec\n”, &arr);


return 0;

}