I am getting error that I am doing an invalid conversion from int to char. I am using sprintf to change a user entered hour called ETHour to char, then strcat more chars onto it to create a time then trying to post it to a window..

char cETime[8], Min[8], AMPM[8];
int ETHour;

sprintf(cETime, "%i", ETHour);
strcat(cETime, ":");
strcat(cETime, Min);
strcat(cETime, " ");
strcat(cETime, AMPM);
SetWindowText(IDC_EASTERN_TIME, cETime);

IDC_EASTERN_TIME is (presumably) an integer control id. You need an HWND to pass to SetWindowText. If you have an hwnd to your dialog (or whatever) window, try this: SetWindowText ( GetDlgItem ( hwndDialog, IDC_EASTERN_TIME ), cETime ); Also, cETime has too-little space allocated to it. It should be at least 24; may as well make it 32.

That worked great.. final code was...

sprintf(cETime, "%i", ETHour);
strcat(cETime, ":");
strcat(cETime, Min);
strcat(cETime, " ");
strcat(cETime, AMPM);
SetWindowText(GetDlgItem(hWndDlg, IDC_EASTERN_TIME), cETime);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.