'How can I put more than one character from an element of string array inside TEXT as it must ba a pointer to a character [ outtextxy(X , Y, TEXT) ]?

I want to put values from arr[] to the outtextxy() function. I can't declare arr[] as char because there are values like 10, 11 ... in it and the outtextxy() function does not allow me to put a string there. Ive also tried to make a pointer that holds value of arr[] but it does not work.

#include <stdio.h>
#include <graphics.h>
#include <cmath>

int main()
{
int a = 450, b = 450;
int midX = a/2, midY = b/2;
initwindow(a, b);

char t[50];

std::string arr[] = {"3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "1", "2"};
std::string* ptr = &arr[2];

for (int x=0; x<12; x++){

    int angle = 60*x;
    double rad = (3.14*angle)/360.0;
    int r = 155;

    outtextxy(midX+r*cos(rad) , midY-155+r*sin(rad)+100, ptr);
    getch();
}

getch();
closegraph();

return 0;
}


Solution 1:[1]

I've found the answer after a lot of searching. I have to make arr[] not a string but a 2d char array. It solves all the problems.

#include <stdio.h>
#include <cmath>
#include <graphics.h>

int main()
{
int a = 450, b = 450;
int midX = a/2, midY = b/2;
initwindow(a, b);

char t[50];

char arr[][3] = {"3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "1", "2"};
char* ptr = &*arr[2];


for (int x=0; x<12; x++){

    int angle = 60*x;
    double rad = (3.14*angle)/360.0;
    int r = 155;

    outtextxy(midX+r*cos(rad) , midY-155+r*sin(rad)+100, ptr);
    getch();
}

getch();
closegraph();

return 0;
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mr. Developer