|
doctorpi wrote:
I want a list...
But the subject indicates an array. I'll show an example for an array.
int nNumbers[100000];
for (int x = 0; x < sizeof(nNumbers) / sizeof(int); x++)
nNumbers[x] = rand();
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks
But maybe I haven't explained me well.
At the beginning I have an array where nNumbers[i]=i; then I have 100.000 numbers. After the process that I don't know how to do I want to have the array with all the numbers from 0 to 100.000 but unsorted.
I'm thinking in exchange 2 positions N times, but how I can generate a number between 0 and 100.000 because rand() is not valid for me.
Thanks again
Doc
|
|
|
|
|
doctorpi wrote:
...how I can generate a number between 0 and 100.000 because rand() is not valid for me.
You are right. rand() returns a maximum value of RAND_MAX . Here is a pseudo-random number generator that I've used in the past:
static unsigned long Seed = 1;
#define A 48271L
#define M 2147483647L
#define Q (M/A)
#define R (M%A)
double Random( void )
{
long TmpSeed;
TmpSeed = A * (Seed % Q) - R * (Seed / Q);
if (TmpSeed >= 0)
Seed = TmpSeed;
else
Seed = TmpSeed + M;
return (double) Seed / M;
}
void Init( unsigned long InitVal )
{
Seed = InitVal;
}
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
Thanks guys
I think I've got it.
Doc
|
|
|
|
|
Hi all,
We hope customers get new info from our web on time.
I want to do in this way:
add a web-page which includes some texts, i.e. "expire", "update" etc.
when program (used by customers) is running, it reads the web-page (it is hidden from customers) and does something according to texts on the page.
I don't want to use tcp/ip - we only have simply tasks.
do you know how to download a web-page silently (users don't know)?
or any other suggestions for my needed?
thx
includeh10
|
|
|
|
|
Why do you want the user to use an application which read a web page, why not use only the web page, with no application. Maybe you should use the CHTMLView, or something like that, I forgot the class
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
I know try using CWebBrowser
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
Hi, I am trying to use the PostMessage function by importing it through DLL import in C# with the following definition.
[DllImport("user32.dll")]
static extern bool PostMessage(IntPtr hWnd, int msg, Int32 wParam, IntPtr lParam);
Can someone give an example of what you would pass in order to get a keystroke, and a mouse click? Really, I do not understand what needs to go in for wParam, or lParam.
Thank you for your help in advance.
|
|
|
|
|
It depends what you need at the other end; there's a simple answer and a complicated one.
The simple answer is to look in MSDN for:
Keystroke: WM_CHAR
Mouse click: WM_xBUTTONy (where x is L or R and y is UP, DOWN or DBLCLK)
It can be more complicated if you need WM_KEYDOWN , WM_KEYUP , WM_SYSKEYDOWN , WM_SYSKEYUP , WM_SYSCHAR and so on.
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
struct S2
{
WORD w0;
};
struct S6A
{
WORD w0;
DWORD dw0;
};
struct S6B
{
WORD w0,w1;
WORD w2;
};
struct S10A
{
WORD w0;
DWORD dw0;
DWORD dw1;
};
struct S10B
{
WORD w0,w1,w2,w3,w4;
};
if use sizeof() to calculate size of structs above, they are
2, 8, 6, 12, 10 respectively (tested on windows OS - not DOS).
align? why in this way?
includeh10
|
|
|
|
|
Structs/classes are padded internally to make members aligned properly (most common CPUs other than x86 will fault on unaligned memory access). So in the case of:
struct S6A
{
WORD w0;
DWORD dw0;
}; if dw0 came right after w0 in memory, it would not lie on a DWORD boundary, so 2 bytes of padding are added to make dw0 aligned. This behavior can be changed with #pragma pack .
--
I'm Michael Dunn and I approve this post.
Vote Trogdor in oh-four!
|
|
|
|
|
By default struct s are aligned on 8-byte boundaries. If you are having alignment problems, check out the #pramga pack directive, or the /Zp compiler switch.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DWORDS can only appear at offsets which are a multiple of four. (sizeof(DWORD))
Compilers are required to lay out a structures members in the same order as they are declared.
Put these two together... the compiler must insert padding.
|
|
|
|
|
struct S2
{
WORD w0;
};
why sizeof(S2) is 2, not 4?
includeh10
|
|
|
|
|
because there's "nothing" after, is that a good answer ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Why do you want to know?
The compiler can do whatever it wants. Your particular compiler has choosen to do it this way. Unless you have told the compiler to do otherwise the compiler is allowed to do anything it wants.
In most cases this question is invalid - you do not need to know! IF you have an exception (they do exist, don't get me wrong), beware that the answer will change when anything else changes. Not just the CPU or compiler, but sometimes different compiler options will cause different things to happen!
|
|
|
|
|
How can i add a splash screen in mfc
Learner always
|
|
|
|
|
Hi,
Click on "Project" in the main menu bar. Select Add To Project->Components and Controls. Select Visual C++ Components from the Components and Controls Gallery Dialog box and click on Splash Screen and finally click on "Insert" button. Sit back and relax, rest is done by MFC for you. You just need to design the bitmap for ur Splash Screen.
Vikram Kashyap
"You will never fail until you stop trying"
|
|
|
|
|
How to add in .net .What if my application is dialog.
Learner always
|
|
|
|
|
I am creating a chat application .I have used a rich textbox for message writing.
I want to add emotions (small pictures)like in yahoo or "MSN" using toolbar and shotrcuts such as " " etc.
Can you help me.
Learner always
|
|
|
|
|
Hi all,
i use CWebBrowser2 (activeX control) on a dialog to display a web page.
the control shows Vertical scrollbar always, I want to hide the Vertical scrollbar because the web page just includes a small image - it will be much nicer if no vertical scrollbar.
I tried ctrl.ShowScrollbar(SB_VERT,0) and more, anyway the bar is there - i can't hide it.
can u help?
thx
includeh10
|
|
|
|
|
You can put this in the page itself:
<body scroll=no>
--
I'm Michael Dunn and I approve this post.
Vote Trogdor in oh-four!
|
|
|
|
|
I think you need to set this in the HTML code itself. ( I just can't recall exacly what is the tag property ... )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
thx for u 2,
the tag works great!
I spent for one hour last night on this without any result!
cheers
includeh10
|
|
|
|