|
-
Dec 17th, 2001, 11:30 PM
#1
Thread Starter
Fanatic Member
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.

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Dec 17th, 2001, 11:39 PM
#2
Code:
#include <stdio.h>
//...
double t=sqrt(10)
char T[MAX_LENGTH];
sprintf(T,"%d", t)
//...
try that.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Dec 17th, 2001, 11:45 PM
#3
Thread Starter
Fanatic Member
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?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Dec 18th, 2001, 10:39 PM
#4
Thread Starter
Fanatic Member
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?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Dec 19th, 2001, 02:20 PM
#5
Monday Morning Lunatic
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|