How can I print a string to the console at specific coordinates in C++?

后端 未结 7 1253
温柔的废话
温柔的废话 2020-12-01 15:24

I\'m trying to print characters in the console at specified coordinates. Up to now I have been using the very ugly printf(\"\\033[%d;%dH%s\\n\", 2, 2, \"str\");

7条回答
  •  借酒劲吻你
    2020-12-01 15:43

    void screenpos(int x,int y,char textyowanawrite[20])
    {
    //printf for right shift
    // \n for downward shift
    //loops through the rows and shifts down 
    for(int row=0;row<=y;row++)
    {
    printf("\n");
    for (int i = 0; i < x; i++)
    {
    printf("%s "," " );
    }
    }
    printf("%s ",textyowanawrite );
    } 
    

    //this should work to certain extinct only problem is u cant go from somewhere like 4,4 to 2,2 thats the problem

提交回复
热议问题