-
Convert double to Char/
Hello, I'm trying to convert a double to a char. how to acomplish that?
Code:
double t=sqrt(10)
MessageBox(NULL,t,"",0);
Always gives me an error, cannot convert double to char. Please give advice on how to solve this. Also, when I'm trying to use strcpy and strcat
Code:
double t=sqrt(10)
char T[MAX_LENGTH];
strcpy(T,"Hello this number is: ");
strcat(T,t);
Won't work. How to solve this as well? Thanks.
-
Code:
#include <stdio.h>
//...
double t=sqrt(10)
char T[MAX_LENGTH];
sprintf(T,"%d", t)
//...
try that.
:)
-
What happen?
Code:
#include <windows.h>
#include "resource.h"
#define MAX 256
#define TIMER_10SEC 1
HWND dlg;
BOOL CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam){
double x=LOWORD(lParam),y=HIWORD(lParam);
SetTimer(hwnd,TIMER_10SEC,1000,NULL);
switch(msg){
case WM_INITDIALOG:
MessageBox(hwnd,"'Look, I can be the meanest son of a ***** in this school!'","Mr. Olds says",MB_ICONEXCLAMATION|0);
break;
case WM_CLOSE:
DestroyWindow(hwnd);
PostQuitMessage(0);
break;
case WM_KEYDOWN:
switch(wParam){
case VK_ESCAPE:
SendMessage(hwnd,WM_CLOSE,0,0);
break;
case VK_F1:
MessageBox(NULL,"hey","",0);
break;
}
case WM_TIMER:
switch(wParam){
case TIMER_10SEC:
MessageBox(NULL,"Ms. Van Norton Suk!","...",MB_ICONEXCLAMATION|0);
break;
}
break;
default:
return 0;
}
return TRUE;
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd){
MSG msg;
dlg=CreateDialog(hInstance,MAKEINTRESOURCE(main_prog),NULL,WndProc);
if(dlg==NULL){
MessageBox(NULL,"Cannot create Windows, please recheck your system","From TZ",MB_ICONEXCLAMATION|0);
return 0;
}
ShowWindow(dlg,nShowCmd);
while(GetMessage(&msg,NULL,NULL,NULL)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
I want the Timer to be occured on the MAIN WINDOW, not the MessageBox. How?
-
sprintf();
Hello, every experts, I would like to know how to do this:
Code:
double Y=sqrt(10);
char X[MAX_LENGTH];
sprint(X,"%d",Y);
MessageBox(NULL,X,"",0);
When the messagebox pop up, it's something not sqrt of 10, and when I change 10 to 100, it gave me 0. What happened?
-