|
hi!
I am using the following code to generate a random string. But each time i get the same string output. Can anyone help.
char myarray[22];
char* CGeneratorApp::GenerateString()
{
myarray[21]='\0';
for(int k=0;k<21;k++)
{
myarray[k] = (char)(((int)rand()%25)+65);
}
char first[2];
intUsed++;
sprintf(first,"%d",intUsed);
if(intUsed<10)
{
first[1]=first[0];
first[0]='0';
}
first[0]=(char)((int)first[0]+27);
first[1]=(char)((int)first[1]+27);
myarray[8]=first[0];
myarray[10]=first[1];
AfxMessageBox(myarray);
return myarray;
}
Thnx in advance
|
|
|
|
|
Please take a look into the MSDN under command 'srand' !!!
Try to extend your code as follow:
#include <stdlib.h>
#include <time.h>
..
...
srand ( (unsigned)time (NULL) );
for(int k=0;k<21;k++)
{
myarray[k] = (char)(((int)rand()%25)+65);
}
...
...
greets al
|
|
|
|
|
Dont forget to call randomize before calling the rand fucntion.
1.Why do people not wearing a wrist watch look at their wrist for time when people ask for time.
2.Why do people ask for time from people who are not wearing a wrist watch.
Prakash,
India.
|
|
|
|
|
sorry, the includes are:
#include <stdlib.h>
#include <time.h>
greets al
|
|
|
|
|
|
I've two separate dialogs (Dialog1,Dialog2), each having its own class. Dialog1 has an Edit box which I need to write to, from Dialog2. In Dialog1 I normally use
CString Status;
GetDlgItemText(IDC_EXIT_BOX_ONE, STATUS);
SetDlgItemText(IDC_EDIT_BOX_ONE, "TEST APPLICATION");
However If I do the very same in Dialog2 nothing appears in the Edit box of Dialog1.
Any Suggestions.
(Note required to use GetDlgItemText to maintain all information on the Edit box)
Kind Regards
Caoimh
|
|
|
|
|
How will it work???
IDC_EXIT_BOX_ONE is a dialog item of the other dialog.
to do this you need to have the pointer of the other dialog
CDialog1 *pDlg1;
so from the second dialog
//in CDialog2
you say
pDlg1->GetDlgItemText(IDC_EXIT_BOX_ONE, STATUS);
pDlg1->SetDlgItemText(IDC_EDIT_BOX_ONE, "TEST APPLICATION");
1.Why do people not wearing a wrist watch look at their wrist for time when people ask for time.
2.Why do people ask for time from people who are not wearing a wrist watch.
Prakash,
India.
|
|
|
|
|
I've found there are loads of macros in the windowsx.h header file. Anyone know if there is a listed description of these macros available, or do I just plough through this header? Thanx.;)
|
|
|
|
|
There are some macros not documented in the MSDN but most of them are...
Some macros are for internal use. But you will lot of things if you go throuh the header files of the windows operating system.
1.Why do people not wearing a wrist watch look at their wrist for time when people ask for time.
2.Why do people ask for time from people who are not wearing a wrist watch.
Prakash,
India.
|
|
|
|
|
Hi
I am new to VC++ and have given the task to connect VC++ with the Oracle,so plz some body help me i have no idea from where i have to start caze i am really unable to understand how the VC program control flows so plz help me in that also can i use the ADO componenets for that tell me in detail and if possible plz refer me a tutorial including source code for it.
Thanx
alex303
|
|
|
|
|
I have a class structure as follows:
Class A: public CObject
{
}
Class B: Public A
{
}
Now I want to serialize pointer class B using CArchive.
How can this be done?
Regards
|
|
|
|
|
|
in .h file
class A : public CObject
{
public:
DECLARE_SERIAL( A )
A(){};
void Serialize( CArchive& archive );
};
in .cpp file
IMPLEMENT_SERIAL( A, CObject, 1 )
void A::Serialize( CArchive& archive )
{
CObject::Serialize( archive );
if( archive.IsStoring() )
else
}
Hope this code help you , for further reading MSDN has good explanation for
serialization.
1.Why do people not wearing a wrist watch look at their wrist for time when people ask for time.
2.Why do people ask for time from people who are not wearing a wrist watch.
Prakash,
India.
|
|
|
|
|
I would like to see my binary tree nodes and their data contents by using a tree control, but I would like to show it in horizontaly and from top to bottom expanding way, not the vertically way as in the explorer style tree control. This can be implemented using available tree controls or does this require a fully new implementation ?
|
|
|
|
|
I dont think there is any standard control that you looking for...
I guess its a complete implementatino from the scrach, unless you find one already implemented, but no, no standard control.
1.Why do people not wearing a wrist watch look at their wrist for time when people ask for time.
2.Why do people ask for time from people who are not wearing a wrist watch.
Prakash,
India.
|
|
|
|
|
I want to import an autocan drawings DWG or DXF and save in my app. and then redraw the drawing in my app
please help me
|
|
|
|
|
|
Hello everybody,
Does anybody know, how I can convert an in-proc server project written in ATL 3.0 (VC++ 6.0) to local server (exe version) or vice versa?
I mean that what changes, I have to make to the project settings and maybe to the source code and/or other files in the project? I have seen a sample project "ADOSAMP" that has several project settings for building dll or exe versions.
Regards,
Roozbeh
|
|
|
|
|
To convert inproc to out of proc you cant do it by project settings.
You need to construct new project as ATL exe service, If you inproc server is using MFC then lot of troblem (coz ATL-exe service by default does not suppor MFC, you need to add MFC support manually)
Then add all the files that you have added to the dll, like .h ,.cpp,.idl fiels to the new workspace and little changes in each new .h.cpp file about the #includes will let you migrate,
But frankly its very laborious thing to do.. but this is the way to be done.
1.Why do people not wearing a wrist watch look at their wrist for time when people ask for time.
2.Why do people ask for time from people who are not wearing a wrist watch.
Prakash,
India.
|
|
|
|
|
Hi,
I've created a console application and want to hide the (console) window when the app. is started. I know you can achieve this by calling 'ShellExecute', but that's not what i want. I remember i did this at one point by using '#pragma comment (linker , *bladiebla*)'. I don't exactly remember the rest, but i think it was something like that. Can anbody help me out here?
Thanks
Er zit een korstje op mijn aars.
|
|
|
|
|
forgettaboutit.....already found it... '#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")'...this works just fine.
Er zit een korstje op mijn aars.
|
|
|
|
|
You can do the same thing in project settings->link/catagory output Entry-point symbol.
1.Why do people not wearing a wrist watch look at their wrist for time when people ask for time.
2.Why do people ask for time from people who are not wearing a wrist watch.
Prakash,
India.
|
|
|
|
|
HI,
I have a program that is loaded in memeory and i know its memory address , so how can i launch/Run that progrmam without using ShellExecute(..) etc.
thanx
|
|
|
|
|
i don't understand the problem but here is a solution may be it is what u want
from ur program load another program in YOUR memory not by ShellExecute or anything simply read the file and store the contents
then simply do a jump to that address
_asm jmp (wherever u want)
don't forget to call jmp or ret from the loaded code to ur own code so u can exit properly
Hope all this makes sense
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
I dont thing this is going to work with exe files, for exe file you need to recalculate the far calls present in the exe file also rebasing problem needs to be taken care...
Your solution is rite but for .COM files.
1.Why do people not wearing a wrist watch look at their wrist for time when people ask for time.
2.Why do people ask for time from people who are not wearing a wrist watch.
Prakash,
India.
|
|
|
|