|
I'm sure you meant to respond to marcdev instead.
See here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
this is my code
it seems alrite to me but the output seem weirld since it displayed >>1.8999e-007<<wich i="" have="" no="" idea="" where="" this="" came="" from="" pls="" help
run="" it="" and="" see="" for="" urself
#include="" <iostream="">
#include <string>
#include <time.h>
#include <iomanip>
using namespace std;
int main (void)
{
float a2=5.55;
int star=0;
float sux,a3; //test
float money[6] = {1.00,0.50,0.20,0.10,0.05,0.01};//types
int moneychange[6] ;//change
for (star=0;star<6;star++)
{
moneychange[star] = a2 / money[star];
a2 = a2 - (money[star] * moneychange[star]);
cout << moneychange[star]<
|
|
|
|
|
What's wrong ? It's the result of your maths ...
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
Ok, the problem is the way doubles are handled which causes your "bug". A rounding factor gets accumulated so to do what you want to do I think you best introduce an extra variable...
Following code works:
<code>float a2=(float)5.550;
float money[6] = {(float)1.00,(float)0.50,(float)0.20,(float)0.10,(float)0.05,(float)0.01};//types
int moneychange[6] ;//change
float accounted=0;
for (star=0;star<6&& accounted < a2;star++)
{
moneychange[star] = (a2-accounted) / money[star];
accounted += money[star] * moneychange[star];;
cout << moneychange[star]<<endl;
cout << a2-accounted<<endl;
}</code>
|
|
|
|
|
|
well.....i m a beginner n i m asiigned he task to write a code in vc++ that shoule ensure that "work ofline " option in file menu shoud remain unchecked ......... can any body help me\?????????????????????????????????
|
|
|
|
|
miss taqdees wrote:
can any body help me
Sure. What exactly do you need help with? Show us the code that is giving you trouble and I'm confident that someone here will critique it for you. If, however, you have not bothered to write any of the code yourself and are simply wanting someone to do it for you (i.e., this is the opposite of help), best of luck.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
surely i dont wish for someone to write the code for me...........its just that can somebody tell me any functions or classes that might help me............like how to access internet explorer with c++ and how to get access to file menu etc..............not CODE...only some guiging material.................thanks
|
|
|
|
|
Someone please tell me how to use lineMonitorTones(.
I want to detect ringback and dialtone.
Thank you
|
|
|
|
|
Hi,
I want to use the string in switch case statement. Can you please help me.
Thanks
|
|
|
|
|
I can only guess and believe you might want to do something like this:
<br />
switch (myString) {<br />
case "Blue":<br />
...<br />
break;<br />
case "Red":<br />
...<br />
break;<br />
...<br />
}<br />
Trouble is, the C or C++ languages don't do that. C# does. Thus, one solution is to use C#. If you want to use C/C++, you must use nested if/else clauses to emulate the same effect, something like so:
<br />
if (_tcsicmp(myString, _T("blue")) == 0) {<br />
...<br />
} else if (_tcsicmp(myString, _T("red")) == 0) {<br />
...<br />
...<br />
}<br />
Doesn't look as nice, but, compared to the above fictivious switch statement, gives you control over the comparison algorithm (e.g. use _tcsicmp for case-insensitive comparison, or _tcscmp for case-sensitive comparison), etc.
|
|
|
|
|
You cannot use a string in switch cases - the cases have to be constant numberic values.
If the strings are not known at compile time, then you have to use if...else if...else
statements.
If they are known at compile time, then you can precompute hashes of the case strings,
and switch on a hash of the string you want to switch on. Um, that wasn't very clear,
was it?
void DoSomethingDependingOnString (LPCTSTR szSwitchable)
{
switch (ComputeHash(szSwitchable))
{
case 0x4wfe:
DoFirstThing ();
break;
case 0xfg13:
DoSecondThing ();
break;
default:
DoDefaultThing ();
break;
}
}
I hope that was little clearer.
Iain.
|
|
|
|
|
I would recommend not to use the hash approach, for at least these:
i) it is hard to maintain - always think a couple of years and several generations of fellow programmers ahead. Who's going to remember how to create the keys, why and when?
ii) it is doomed to fail - hash keys are not unique, so there is a chance that two different strings produce the same key.
|
|
|
|
|
berndg wrote:
ii) it is doomed to fail - hash keys are not unique, so there is a chance that two different strings produce the same key.
If you have a finite set of possible strings known at the program development time, you can create a "perfect" hash function[^] that doesn't cause collisions.
|
|
|
|
|
|
The actions include save as , print, local copy, copy on the net and so on.
My english is very poor!
|
|
|
|
|
Your English is fine, but your explanation is a bit weak. Exactly what is it that you want to do?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I want to monitor the operations to a file which like save as, print, local copy, network copy, attach to a mail and so on.
Have I explain my request clearly?Please help me,thanks!
|
|
|
|
|
Perhaps you are interested in ReadDirectoryChangesW() or FindFirstChangeNotification() . If not, the items you have mentioned are typically found on the menu of an application. What that application does when a particular menu option is selected is indeterminate. Monitoring that would be a chore at best.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
let me tel u in a simpler way,
my application waits for an event from a server. if the request is timed out, the application should terminate but shldn't freeze waiting for the event from the server.
//i tried to use a worker thread which will monitor the value of the
variable "eventDelay"
//so before requesting the event from the server, i'd do like this
int eventDelay=0;
CWinThread *ct=AfxBeginThread(threadtimeout,this);
getEventFromServer(&....,&....&....);
ct->SuspendThread();
//in the thread,(threadtimeout)
void threadtimeout()
{
do
{
Sleep(1000);
eventDelay++;
if (eventDelay>10)
exit(0);
}while(true);
}
but still the application gets hanged up if the server's not sending the event.. . why..? how to timeout and exit?
regards,
Rookie
|
|
|
|
|
With the information you've provided it seems that you don't need a thread for that. You could use a simple timer (SetTimer) that terminates the app when fires up (OnTimer).
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
can u give me a smal example?
regards,
Rookie
|
|
|
|
|
sorry for the bad naming convention... the function threadtimeout is not to timeout the thread.. its for timing out getEventFromServer() function... please help
regards,
Rookie
|
|
|
|
|
Is it a dialog based application?
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
ya... MFC dialog..
regards,
Rookie
|
|
|
|