Liberty Unleashed

Off Topic => General Chat => Topic started by: Romop5 on November 04, 2011, 04:08:16 pm

Title: String in Windows elements
Post by: Romop5 on November 04, 2011, 04:08:16 pm
For example I have:
Code: [Select]
char chError[] = "Your PC is low";
int  iErrorId = 55;
And I want write it on screen by MessageBox:

Code: [Select]
MessageBox(NULL, "Error iErrorId: chError","Error",MB_OK);
How can I code it correctly ?
Thanks
Btw: I know that I can't get iErrorId between ""
Title: Re: String in Windows elements
Post by: Force on November 04, 2011, 04:20:37 pm
I'm presuming your working from C++ here? Based off that assumption...

Code: [Select]
#include <stdio.h>

char szError[] = "Your PC is low";
int iErrorID = 55;
char szErrorMessage[25];

sprintf( szErrorMessage, "Error %d: %s", iErrorID, szError );

MessageBox( NULL, szErrorMessage, "Error", MB_OK );