need help type casting

polarbear6

Golden Member
Jul 14, 2008
1,161
1
0
iam no programmer
i only do some casual php scripting
i mostly do web programming
i seldom do programming and i seldom ^ 10 do windows programming
and even if i do i do it in in vb or vc#

but this time i decided to get my hands dirty and do some winapi programming(i know its a big step but have to do it)

EDIT:THIS IS IN C, my god iam becoming so forgetful

know the problem is i have a button which on clicking should add two numbers and show them in a message box
but how to type cast the sum to a string or a dword
i tried (variabletype) variable value
but my programming just crashes :eek:
what can be the reason

also i am looking for nice tutorials on winapi programming
and some tutorials on pointers ....

 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
Assuming C:

char buff[16];
int myInt = 7;
snprintf(buff,16,"%i",myInt);

// Now pass buff to your MessageBox
 

polarbear6

Golden Member
Jul 14, 2008
1,161
1
0
still the problem persists
it just crashes when i run it
either the earlier way or this way

 

polarbear6

Golden Member
Jul 14, 2008
1,161
1
0
nvm i was pointelessly coding(experimenting)

but how to add two numbers in windows.h
like
int a =7;
int b = 8;
int c = a + b;
when i tried it i get this error
initalizer element is not constant



 

mundane

Diamond Member
Jun 7, 2002
5,603
8
81
It sounds like you're trying to use them as global variables. Try inside of a function - if it's just throwaway code, main().
 

polarbear6

Golden Member
Jul 14, 2008
1,161
1
0
well is it possible to make interactions to outside world from inside the int main()
i mean i need to get a message box for the sum
but then is it possible to throw a message box from with in int main()

and besides if i open a main()
my window wont show up