|
Hi how are you,
Do you know how I could plot some histograms in C++.
This whole thing should look something like that:
"There are 4 values for each #
Histogram starts at 10.000 with a step size of 5.000.
10.000 : ########
15.000 : #############
20.000 : #######
25.000 : #########################
30.000 : ###############
There are 15 inputs not in the range 10 to 35.
Can you tell me how I could proceed to plot a histogram in C++ like this. It should involve
• A function to read the input values and keep the count in an array.
• A function to obtain the maximum value in a given array.
• A function to calculate an integer division, but with rounding up.
• A function to plot the histogram.
• The main function to drive the whole program.
If you have any suggestions or some good links to any website that might concentrate on histograms, would be of great
help for me.
Thanks
|
|
|
|
|
Go to http://root.cern.ch
and download the Root package. This includes an C++ Interpreter and many visualization
classes in C++. Including 1,2,3-D Histograms, Fitting algorithms 3D-Functions and much more.
e.g The C++ Script: http://root.cern.ch/root/html/examples/hsum.C.html
produces this Histogram
http://root.cern.ch/root/html/examples/gif/hsum.gif
Hope this helps.
Yours,
Alois Kraus
|
|
|
|
|
This sounds too much like a school assigment, please start writing code, and we'll be really happy to help you with specific questions!
I may sound harsh, but that's the way it is. but I will give you a hint, not a programming one, but a generic one :
When facing a problem like this, first, start by figuring out how you'd do this manually, write things down using real words and you find that the answer is really simple and that "translating" it to any programming language is easy!.
Max.
|
|
|
|
|
Go see your professor or your teaching assistant.
|
|
|
|
|
Hi there,
Would anyone happen to know how I could go about sending an email + attachment using the user's default mail program, such as Outlook Express? Well, really all I need is to pop up the Outlook Express mail composition with stuff like body text, subject, and email attachment already filled in. (The email attachment is the hard part, as the other stuff can just be put into a mailto tag.)
Any ideas?
Much thanks!
swine
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
|
Thanks! Actually I just stumbled upon this a couple of minutes ago and was able to send out an email using MAPI. The problem is that the user still has no access to their address book from which they can pick email names.
What I would really need to do is pop up the email composition window of the default email program. Is this possible through mapi?
Thanks!
swine
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
Ooops nevermind, I found the MAPI_DIALOG flag .
cheers!
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
MAPI works nicely.
Shog9
------
If you really what to get shitfacde tell a crowded bar that is is yourt borthday and hife your wallet. you ka will many more friends.
- David Wulff, Brithday selebrations, 9/19/02
|
|
|
|
|
Thanks! Actually I just stumbled upon this a couple of minutes ago and was able to send out an email using MAPI. The problem is that the user still has no access to their address book from which they can pick email names.
What I would really need to do is pop up the email composition window of the default email program. Is this possible through mapi?
Thanks!
swine
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
Ooops nevermind, I found the MAPI_DIALOG flag .
cheers!
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
if i hava a class
class a
{
int a;
CString str;
};
i want to write its object into a file and send that file through a network to different computer and i want to recive that object again if i have the same class there.
may i read the same object on network from a file?
any body can explain my idea into code like
how to write object into file ?
how to read object on the network (having same class there) from file ?
r00d0034@yahoo.com
|
|
|
|
|
See Serialize (u must thus derive ur class from CObject)
archives and using archives with sockets!
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi.
I am working on a simple client-based winsock Windows program. The program works well under the current software design. However, I discovered a huge resource problem.
The program support multiple simultaneous connections. I use the WSAAsyncSelect() I/O model to handle I/O. Everything works well. I implemented two worker threads. One thread sends data. The second thread receives data. WSAAsyncSelect() sends messages via Windows queue and update the program on FD_WRITE, FD_READ, etc. Again, the program works as planned.
I discover a huge resource problem. The program takes up all CPU resource as it makes more and more socket connnections. In other works, the program stalls if the user attemps to makes ten or more connections. CPU usage is 100%.
I re-read Network Programming for Microsoft Windows, Second Edition by Anthony Jones and Jim Ohmund. If I am not mistaken, you do not need workers thread for winsock if you use a non-blocking I/O such as WSAAsyncSelect().
I would like to know if there is a flaw in the program design. My thought right now is that this design will not work because of the worker threads. There is no way Windows can handle too many worker threads. However, let say I implemented WSASend() and WSARecv() solutions directly in the primary thread (main applications), I believe that will lock up Windows or at least the program. For example, if I implement a while loop that calls WSARecv() until it returns 0, that will lock up the program. Is that right?
Thanks,
Kuphryn
|
|
|
|
|
is there a while ( true ) loop somewhere??
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Yes, the problem definitely resulted from a while-loop. I am in the process of implementing a different approach to the algorithm.
I am debug a weird problem. For some reason, I cannot close an event handle. For example,
-----
HANDLE mEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL);
...
// This code crashes the program.
// Visual C++ debug says the error has something to do with an invalid
// handle.
::CloseHandle(mEvent);
-----
Kuphryn
|
|
|
|
|
Did you check that your handle was valid before trying to close it?
Signature space for rent. Apply by email to....
|
|
|
|
|
is the event being created??
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I think your best way of implementing this is to make new threads for each client connection.
Then, within the read thread, you can have a loop similar to this, which consumes negligible CPU time:-
WSAEVENT event;
WSANETWORKEVENTS netevents;
event = WSACreateEvent();
WSAEventSelect(s, event, FD_READ | FD_CLOSE);
DWORD result, lIdleTimeout;
lIdleTimeout=0
while (TRUE)
{
result = WSAWaitForMultipleEvents(1, &event, FALSE, 100, FALSE);
if (result == WSA_WAIT_TIMEOUT)
{
if (++lIdleTimeout > IDLE_CONNECTION_TIMEOUT)
{
closesocket(s);
return FALSE;
}
continue;
}
lIdleTimeout=0;
WSAEnumNetworkEvents(s, event, &netevents);
if (netevents.lNetworkEvents & FD_CLOSE) {
printf ("socket closed\n");
return TRUE;
}
if (netevents.lNetworkEvents & FD_READ) {
continue;
}
}
The key here is that WSAWaitForMultipleEvents() is very very lightweight. This example was for a connection thread for a server type socket, but implementing a similar theory in a client socket is simple.
Signature space for rent. Apply by email to....
|
|
|
|
|
Thanks.
The wait function (single) I use works well. I am just having a problem closing the handle of the event object.
Kuphryn
|
|
|
|
|
What is the message that a dialog receives when you bring another application on top of it?
|
|
|
|
|
There are most likely several; use Spy++ to find the ones you want. If the dialog was previously active, you'll most likely get WM_KILLFOCUS , WM_ACTIVATE , and possibly WM_ACTIVATEAPP .
Shog9
------
If you really what to get shitfacde tell a crowded bar that is is yourt borthday and hife your wallet. you ka will many more friends.
- David Wulff, Brithday selebrations, 9/19/02
|
|
|
|
|
Hello friends,
i would like to catch the WM_SET_TEXT message in an CEdit derived class.
My Function "OnSetText" is called (by Win/framework), but now is my problem: how can i set
the text of the control myself in my function?
When i use SetWindowText, i "call" my own function recursive..!
Thank you very much for your help!
Fiffi
|
|
|
|
|
um....set a flag when you start the recursion and if flag is set then don't recurse and clear the flag??? that's a guess
or on the OnSetText in your class, start a timer (perhaps using flag approach above) and then set the text on the timer call??
Just trying to keep the forces of entropy at bay
|
|
|
|
|
Hello RedZenBird,
I don't would like to call the function recursive!
The command SetWindowText send the WM_SET_TEXT message to windowses to set her text. I would like to catch that message in my CEdit derived class/control (That part is done and OK).
But i would like to the the text in my WM_SET_TEXT-message-handler-function.
When i use SetWindowText my function calls recursive herself!
My question: How can i set the window text without SetWindowText/WM_SET_TEXT ?
(Sorry for my bad english!)
Fiffi
|
|
|
|