Search code examples
c++stringbgiwinbgi

compiler error when trying to show text using winbgi


I have a string that I want to show on the winbgi window using outtextxy.

The problem is outtextxy only takes the pointer of a char array which shows a compiler error.

Here is the code

for(int i=0;i<13;i++){
        setcolor(RED);
        circle(otab[i].x1,otab[i].y1,otab[i].radius);
        string txt="obs";
        txt.append(1,i);
        outtextxy(otab[i].x1,otab[i].y1,txt);
}


Solution

  • if string is a std::string, use txt.c_str()

    https://www.cplusplus.com/reference/string/string/c_str/