|
I looked the file Math.h but there was not any Costand named M_PI.
also I could not find it on MSDN!
are you sure there is M_PI in any header file?
Kamyar Souri
Software Manager
Booria CAD/CAM Systems
www.booria.com
|
|
|
|
|
i think it is a linux/unix def. everytime i've seen this define it was a unix software.
Don't try it, just do it!
|
|
|
|
|
okay i think i will define my own constant rather that searching for a way to use the constant in the header file. previously i had also used it only on an unix system
thanks for the help
|
|
|
|
|
i am developing a class of muliti_precision integers in c++. i have read in some book that on processors such as the Intel Pentium family which offer an "add with carry" intruction. can someone tell me how to write the instruction in c or c++?
thanks.
|
|
|
|
|
Use this code in your c++ code:
_asm {
mov ax,250
adc ax,10
....
}
|
|
|
|
|
thanks. i will give it a try.
|
|
|
|
|
Ok I have no idea what I am doing wrong here:
#include <windows.h>
void main()
{
const char* buffer = "test";
DWORD byte;
HANDLE hFile = CreateFile("C:\\testing.txt", GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
WriteFile(hFile, buffer, NULL,&byte, 0);
CloseHandle(hFile);
}
I am trying to create a file with text like "test". But it will not seem to write the text. It creates the file, but it won't write test.
-Ryan M.
|
|
|
|
|
Look at the parameters to WriteFile() , specifically the 3rd one. It's nNumberOfBytesToWrite . You're passing NULL , which is defined as 0, so you're saying write zero bytes, which is exactly what happens.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Actual sign at the laundromat I go to: "No tinting or dying."
|
|
|
|
|
ok i got it. thanks. I am an idiot for using NULL. I am still learning C++. I know vb much better
void main()
{
const char* buffer = "test";
DWORD byte;
HANDLE hFile = CreateFile("C:\\testin.txt", GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
WriteFile(hFile, buffer, 10,&byte, 0);
CloseHandle(hFile);
}
-Ryan M.
|
|
|
|
|
You're still not passing the right number. Your source buffer is a string, which is 5 bytes long (4 letters plus the terminating 0). You're saying write 10 bytes, which makes WriteFile() read off the end of your string. This may crash, or if not it's writing random bytes to the file. Here's the preferred way:
BOOL bSuccess = WriteFile ( hFile, buffer, strlen(buffer), &byte, NULL ); Notice I'm checking the return value too
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Actual sign at the laundromat I go to: "No tinting or dying."
|
|
|
|
|
thank you so much! I will remember that next time
-Ryan M.
|
|
|
|
|
Ryan McDermott wrote:
I am still learning C++. I know vb much better
Never too late to do the right thing
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
Ryan
1) I'd be a bit worried about the result if you used '10' as the size of the string as shown in your code ... you could crash the program, since you appear to be writing more characters than you have in the buffer ..
2) I'd use "test\0" to init the buffer and
3) strlen(buffer) as the 3rd argument for the WriteFile
'G'
|
|
|
|
|
I didnt realise Michael Dunn had already corrected your use of the '10' .. didnt see his post first time round
sorry all
'G'
|
|
|
|
|
I recently read an article on this website the FAQ for VC++. One thing i was interested in was supposed ability to Staticly Linking MFC info the EXE through PROJECT\SETTINGS and the MFC Tab but it seems i only have the option "Use MFC In A Shared DLL".
Im using VC++ 6.0 Standard Edition is this perhaps why i dont have the other option of static linking?
|
|
|
|
|
|
No there didnt seem to be an option for it i created a Dialog based application.
When installed i chose custom and selected what to install could this have affected some of my options greatly at all?
|
|
|
|
|
|
N4X3M wrote:
Im using VC++ 6.0 Standard Edition is this perhaps why i dont have the other option of static linking?
That's right, some of the cheaper versions of VC don't have that feature. I know I mention that in the FAQ, but it might be in another question.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
"Linux is good. It can do no wrong. It is open source so must be right. It has penguins. I want to eat your brain."
-- Paul Watson, Linux Zombie
|
|
|
|
|
how to set a coloum's width in one raw?
m_Chart.GetDataGrid().SetData(row,i,height,0);
method above can only set a coloum's height.
Tell me,thanks a lot
|
|
|
|
|
Hi,
I'm writing a utility which runs from an icon in the system tray. Right-clicking produces a popup menu which includes several items created dynamically. When the user clicks one of the dynamically added items I want to be able to check/uncheck it. The only problem is I can't get a pointer to the popup menu.
This is how I'm trying it at the moment but it produces an assertion failure. What am I doing wrong?
CMenu* mmenu = ::AfxGetMainWnd()->GetMenu();
UINT state = mmenu->GetMenuState(nID, MF_BYCOMMAND);
ASSERT(state != 0xFFFFFFFF);
Thanks for any advice,
Simon
|
|
|
|
|
A context menu is generally created via TrackPopupMenuEx(). How are you creating the context menu?
Kuphryn
|
|
|
|
|
Many thanks for your response, from your question, I found the problem. I was trying to process the commands as if the menu was still active rather that in its setup procedure. Re-examining TrackPopupMenuEx() helped me to realise that. So thanks again,
Simon
|
|
|
|
|
Hi all hope u can help me . .
I have a simple program that copies files over a wireless network from one comp to a laptop. The program is made to start up as soon as windows xp is loaded up. The hard drive the program is trying to access is a mapped network drive. However because im on a wireless network windows does not make a connection (from what I can see) till about 30 seconds after windows has fully booted up and by this time the attempt to connect my map network drives has gone so windows now thinks the comp with the mapped network drive is now off line. This means that when my program tries to access that hard drive it fails. Of course all I have to do is double click on that hard drive and then windows will connect to it and my program will work. However I was wondering if there is a way I can program it to connect the mapped network drive so I don’t’ have to do it every time I start up windows.
Hope iv made a little bit of sense and thanks for any help any one can give me
Scott
|
|
|
|
|
Just create a timer that mounts the drives, say, 30 seconds after startup.
Kuphryn
|
|
|
|