|
Hi, I am working on VC++ 2003. I am using a string as "char *pchData;". now at some point how can I check that 'pchData' is defined or undefined?
Thanks in advance
|
|
|
|
|
Your code is wrong. NEVER create a pointer without setting it to a valid value, or NULL. Then, just check if it is NULL.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
If you're unsure whether a particular pointer is pointing at a valid address, then something's wrong with your design. In C/C++ it's the program's responsibility to make sure that pointers are either NULL or contain a valid address.
The IsBadXxxPointer() APIs are not reliable (search MS blogs for them, you'll find a few posts about how evil they are).
|
|
|
|
|
We have an application that was written on VC++ 6.0 a few years ago. Today a customer reported that it did not work on their 64 bit laptop (that's all they said 'it doesn't work'!). We are waiting for more info on the problem and we don't have a 64 bit system to try it on.
I just wondered, has anyone had any experience running 32 bit apps on 64 bit machines? Good / bad etc?
Many Thanks,
Ali
|
|
|
|
|
|
Thanks, I will take look at that - sounds like just what I need.
Regards,
Ali
|
|
|
|
|
The first thing that comes to mind is that a 32-bit EXE can't load 64-bit DLLs and vice-versa. For example, a 32-bit IE plugin won't load in 64-bit IE. But without any details, we can only give you WAGs.
|
|
|
|
|
Michael Dunn wrote: we can only give you WAGs.
Fair comment, just checking out the general opinion. I thought a 32bit exe would run on a 64bit machine using WOW, and wondered if anyone else has had any trouble - looks like they haven't - its just my customer!
Thanks Anyway,
Ali
|
|
|
|
|
Alison Pentland wrote: I thought a 32bit exe would run on a 64bit machine using WOW
It can, you just can't mix 32 and 64 bit modules in the same process.
|
|
|
|
|
rand() returns an integer in the range [0 - RAND_MAX]. What if I want to generate random integers in a wider range? is there no escape from calling rand() twice and then multiplying the results?
Is there a continuous random number generator in C++ ?
Thanks,
Avi.
|
|
|
|
|
avimitrani wrote: is there no escape from calling rand() twice and then multiplying the results?
That's not really random, nor does it give a wide enough range. Try calling it twice and shifting the first result to take the bits above the second result.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You could generate a random number between 0 and 1, then multiply that by the bigger number you want to use, e.g.
flaot fRand = rand() / (float)RAND_MAX;
int iValue = fRand * 10000000;
|
|
|
|
|
That won't work: some values might have no chances at all to be picked.
|
|
|
|
|
|
avimitrani wrote: What if I want to generate random integers in a wider range?
You'll need to roll your own. Something like this.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
Iam new to vc++ programming.. iam writing an application which needs some functionalities of some of the activex dlls that I have. Previously static linking to the lib file is done. But right now i need to load active x dlls at runtime. Iam not getting how to instantiate the libraries and loading it at runtime. My platform is Visual Studo 6.0..Can anyone of you help me regarding this. Any help will be appreciated.....
thanks
Bollapalli
bollapalli
|
|
|
|
|
Make sure your ActiveX DLLs are registered. Are these functions graphical or non-graphical components? If they're graphical, you can easily use the dialog editor to put the controls into place, or you could use CWnd::CreateControl to create the controls.
If they're non-graphical components, there are basically two ways to use them. If your components expose interfaces with a vtable (IUnknown-based interface or dual interface), you can use the #import feature of Visual C++. The MSDN docs describe how they are used, and I'm sure you can dig something out about #import here on Codeproject. If not, Google is your friend.
If your component is dispatch only (no vtable), you don't need to #import the ActiveX DLL (unless you've defined structs or typedefs in the typelibrary). Then you can use the COleDispatchDriver class, which helps you to instantiate the component, as well as call methods and manipulate properties. This project could probably benefit you a lot: http://www.codeproject.com/com/xydispdriver.asp[^], as it simplifies the dispatch stuff a great deal.
--
Verletzen zerfetzen zersetzen zerstören
Doch es darf nicht mir gehören
Ich muss zerstören
|
|
|
|
|
I have designed the FTP client application using the WinInet classes . In that for storing the file on the FTP server i have used the CFtpConnection: PutFile(), but it is not retuning true and so the local file is not getting stored at the FTP server.The Error it is saying is that dwd =2(i.e ERROR_FILE_NOT_FOUND )Please help me out in this ....
Is there any other to store the file on the FTP server...
Thanks n Regards
Shikha
|
|
|
|
|
Why don't you work out why it's returning false, and fix it ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks for your immediate reply...
its showing ERROR_FILE_NOT_FOUND when i try to fix it using the GetLastError() but i cannot able to find out the reason..
why it need to find the file on the ftp server it should just get store the specified local file on the server side....
Thanks
Shikha
|
|
|
|
|
Perhaps it can't find the local file ? Or you don't have permission to create the file, so it's not found when it tries to write to it ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Shikha Jain wrote: The Error it is saying is that dwd =2(i.e ERROR_FILE_NOT_FOUND )...
Why was the local file not found?
Without seeing the relevant code, a helpful answer is going to be a guess at best.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
HI Shikha!!! Are u passing the correct path of the file to be uploaded in the CFtpConnection::PutFile() function??? i am new to programming but i had developed a FTP client just a couple of months back.. so, i want u to see if you are passing the correct path in the PutFile() function. and like what Sir David Crow said, without having a look at ur code, we may not be able to give u the correct suggestions.. so, just see if u can post the sample of ur code...
i used the following lines of code to upload a file called as 'test.txt' residing on my 'C' drive.the file will be stored as 'ftptest.txt' on the FTP server.
<br />
CInternetSession sess(_T("MyFtpModule"));<br />
CFtpConnection* pConnect = NULL;<br />
<br />
pConnect = sess.GetFtpConnection(_T());<br />
<br />
BOOL bUploaded = pConnect->PutFile("C:\\test.txt","ftptest.txt",FTP_TRANSFER_TYPE_ASCII,1);
I want others to correct if i am wrong..
Regards, vijay Aroli.
|
|
|
|
|
Dear All,
How do i check a char array and a string ?
Use some simple methods ?
|
|
|
|
|
What do you mean by ... " do i check " .... ??
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|