I am starting up on my first windows program and ran into a bit of a snag.
I need to display a string and a variable to the window. I know how to display a string. I can even display the variable. But I can't display them both. I've tried strcat (string, (char *) &variable) and this will compile, but when I run the program it crashes.
Interseting enough, whenever I use strcat in a console program it crashes as well. So I would like to avoid using that if I can (having no idea why strcat causes the program to fail).
Basically, here is the code I am starting with:
code
-----------------------------------
HDC h;
int a = 9;
char *buffer = "Data: ";
h = GetDC (hwnd);
TextOut (h, 0, 0, buffer, (sizeof (buffer)+1));
ReleaseDC (hwnd, h);
------------------------------------
/code
-or-
code
------------------------------------
HDC h;
int a = 9;
char *buffer = "Data: ";
h = GetDC (hwnd);
TextOut (h, 0, 0, (char *) &a, (sizeof (buffer)+1));
ReleaseDC (hwnd, h);
------------------------------------
/code
-or-
code
-----------------------------------
#include <string>
using namespace std;
.
.
.
HDC h;
int a = 9;
char *buffer = "Data: ";
strcat (buffer, (char *) &a);
h = GetDC (hwnd);
TextOut (h, 0, 0, buffer, (sizeof (buffer)+1));
ReleaseDC (hwnd, h);
------------------------------------
/code == compiles fine but Crashes when it runs
Steve
p.s. I also tried doing consecutive TextOut commands, but couldn't figure out where the last x, y pos of text was printed, so I don't know how to start printing either after or under previous text. Should I be using another function to be writing text to a window?