Author Topic: String in Windows elements  (Read 2336 times)

Romop5

  • Jr. Member
  • **
  • Posts: 83
  • Karma: +2/-1
  • A student of university and creator of LHMP.
    • View Profile
    • LHMP
String in Windows elements
« 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 ""

Force

  • Developer
  • Full Member
  • *****
  • Posts: 204
  • Karma: +6/-2
    • View Profile
Re: String in Windows elements
« Reply #1 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 );
Quote
[Tue - 20:09:35] <&VRocker> CRAP!
[Tue - 20:09:43] <&VRocker> i think i just followed through...
Quote
[Sat - 22:11:56] <~Smapy> [R3V]breSt12 killed [R3V]Jack_Bauer. (Splat)

 

© Liberty Unleashed Team.