|
MoboTech wrote: I'm doing the best I can do my own homework, I've read over 40 pages in my textbook today trying to figure this sh*t out. And I'm stuck.
There's a 99% guarantee that you will not find a chapter titled How to Convert Numbers to Words in said textbook. The only reason I did not use 100% is that there's a chance that some author might use that as an example, but it will never be the focal point of any chapter.
MoboTech wrote: Helping with their homework...
And what have you tried thus far, even if it failed? Remember, Thomas Edison did not improve the light bulb on his first try. He first had to find 1,000 ways that did not work.
MoboTech wrote: If you can't help, don't say nothing.
Easily, Tox can do your homework in all of five minutes, but he's smart enough to know that that won't help you one bit.
All that aside, what was wrong with the suggestion from NS17?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
MoboTech wrote: What do you think tutors are for? Helping with their homework, not doing it for them. And I need a tutor!
I'm not asking people to do my homework. If you can't help, don't say nothing.
I guess the difference is how you ask the question. First such answers are easily googleable. Second if you need a tutor rather than the answer, admit it up front. You'll get far less guff about it than if you admit later it is a homework assignment after someone has done the work for you. And you will get a better answer from one of the regulars demonstrating the methods without giving you the answer. You'll learn more and be more capable of a programmer.
Half of programming is learning where to find the answers. It doesn't matter if you have been programming 1 month or 10 years, you will find something beyond your skill on occasion. What you do and how you do it shows your character and skill both. Thus the trouble you are getting from a few members (and you are actually lucky you got the answers). Some people are interested in getting the vote and giving you the answers because they want to get enough votes to be MVP. They are hurting you for their own benefit. Eventually you will not have them to give you an answer, so how do you find the answer?
A tutor teaches you how to fish so that you can catch your own meal, not hands you a fish. So far I have seen no one showing you how to fish. I am sure you are overjoyed at that now, but eventually you will not have that person to turn to, and you will be lost. No guff from me, only a word of caution: you are only hurting yourself. Next time ask for some one to give you the technique without the answer. One of the regulars, or even one of the MVP wannabes will help you in a way that benefits you, not them.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
MoboTech wrote: I know this crap is hard.
No it's not.
And that's not an insult - it really isn't. You have a classic assignment - it shows up in the first couple of weeks in hundreds of textbooks and courses based on them. And you've been assigned it to teach you something. Of course you can just pull the answers off of a web site, but then what have you learned?
And so i repeat, it's not hard. But if you don't spend the time learning from your course work, you'll find the hard tasks impossible when eventually you do encounter them.
Just a fair warning...
---- I don't care what you consider witty, but at least I do not blather on posting nonsense like Jim Crafton.-- Stringcheese, humbled by Crafton's ability to string together multiple sentences
|
|
|
|
|
Shog9 wrote: You have a classic assignment - it shows up in the first couple of weeks in hundreds of textbooks and courses based on them.
Except the solutions that show up in beginner texts usually suck and don't scale well. *cough* *cough* (plugging my poor, lonely article ).
|
|
|
|
|
---- I don't care what you consider witty, but at least I do not blather on posting nonsense like Jim Crafton.-- Stringcheese, humbled by Crafton's ability to string together multiple sentences
|
|
|
|
|
Jeremy Falcon wrote: plugging my poor, lonely article
at least you have you poor lonely article, I have a mention in yours, and that is it. After that I am just chopped liver.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
El Corazon wrote: After that I am just chopped liver.
Chopped liver with an honorable mention though. Wear that hat proud man.
|
|
|
|
|
Jeremy Falcon wrote: Chopped liver with an honorable mention though.
okay, chopped liver with the occasional good idea.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
You need to work on your Google-fu. Try this[^].
Steve
|
|
|
|
|
|
dear all
1.how to understand the code below: thanks a lot.
const int arraySize = 7;
int frequency[arraySize] = {0};
Note: how to understand {0} above?
2. srand(time(0))
how to understand time(0) above?
thanks a lot.
zhiyuan
Li Zhiyuan
9/26/2007
|
|
|
|
|
li zhiyuan wrote: int frequency[arraySize] = {0};
Initialize all the elements of the array with zero.
li zhiyuan wrote: srand(time(0))
Initialize the random number seed. Initializing with current time provides the random numbers always different. If the seed it not set with time, random numbers will always be same. For example, suppose first number you got is 1562 and the second is 7645, you will get same values in the the same order for each statting of the program. If we initialize the seed with time, first number depends on this seed and so on, since the time is incrementing...
- NS -
|
|
|
|
|
Hi, after programming in c++ for some time, I've decided to start to code in windows environment.
The question is, should I read code until I fully understand windows internals or should I start to make
my own programs and learn on the fly?
I've read Petzold's book but it seems to me that it its not enough to make my own app.
|
|
|
|
|
freeheap wrote: I've read Petzold's book but it seems to me that it its not enough to make my own app.
Do you mean "Programming Windows 5th Edition"? If so...
If you have read and understand everything in that book then you should
have the fundamentals every Windows programmer should know.
It's also the core fundamentals of MFC (and any other framework which wraps the Win32 APIs).
If you intend to write GUI applications and you haven't programmed for an
event/message-driven OS like Windows, then that's probably the most important
concept to understand from the book.
I would recommend starting with a Visual Studio generated Win32 application.
Look at the code produced by the wizard and make sure you understand everything
that's there.
From there you have a basic shell of an application that you can modify and extend
as you learn new APIs.
Just my 2 cents.
Have fun!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I would suggest a blend of both approaches.
Steve
|
|
|
|
|
My approch was doing something, then study...
- NS -
|
|
|
|
|
I suggest for start see create a simple dialog.
|
|
|
|
|
freeheap wrote: I've read Petzold's book but it seems to me that it its not enough to make my own app.
His Windows books are more than enough. I started with his Windows v3.1 book.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Are you planning on using MFC or not? If not, I can recommend this one (although I hear Petzold's is pretty good too)... Clickety[^]
|
|
|
|
|
I am creating a thread in OnInitDialog() of dialog based application as:
hThread = CreateThread(NULL,0,&ThreadAudioProcess,this,CREATE_SUSPENDED,0); and starting it in "Start" button click by ResumeThread(hThread); . The function ThreadAudioProcess() is called this time.
But after I stop it when user click "Stop" by: SuspendThread(hThread); and start it again by ResumeThread(hThread); it is not calling the function. How to start the thread again and call the function?
Thanks & Regards,
Suman
|
|
|
|
|
SuspendThread() will stop the thread at an arbitrary location in the thread's code.
When you call ResumeThread(), execution will resume at the location the thread was
suspended. The thread procedure is NOT a function that gets re-called.
Because of this, SuspendThread() shouldn't be used like this - unless you can figure
out a way to completely control the execution location in the thread.
You really should be doing this another way - communicating with the thread in some
fashion to ensure it's in the state you expect when you pause and restart it.
Also, if you're using any MFC stuff in your thread, you should be using AfxBeginThread()
instead of the CreateThread() API.
If you are not using MFC but you're using any CRT functions in your thread you should be
using _beginthread[ex]() instead of CreateThread().
Mark
*edited for grammar/spleling*
Last modified: 22mins after originally posted --
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark is correct; you shouldn't use SuspendThread /ResumeThread in this way!
The following quote is from MSDN on SuspendThread (the underlines are mine):
This function is primarily designed for use by debuggers. It is not intended to be used for thread synchronization. Calling SuspendThread on a thread that owns a synchronization object, such as a mutex or critical section, can lead to a deadlock if the calling thread tries to obtain a synchronization object owned by a suspended thread. To avoid this situation, a thread within an application that is not a debugger should signal the other thread to suspend itself. The target thread must be designed to watch for this signal and respond appropriately.
The following link may also be of interest:
http://blogs.msdn.com/oldnewthing/archive/2003/12/09/55988.aspx[^]
I suggest you review the documentation more carefully in future.
Steve
|
|
|
|
|
Thank you very much for help from everybody!!
Sure, I will read them and redesign the application.
Best Regards,
Suman
|
|
|
|
|
Hi all. I made some code that i just cant seem to figure out why its not working like intended.
For some strange reason it was working the way i had hoped until i did a final test and it just seemed to do what it wanted, this may sound strange believe me because i think its strange myself, seeing how it worked one minute and then another it doesnt.
I dont need to post the entire code but just the block thats giving me trouble.
<br />
if(connect(dataSock, (sockaddr*)&structSock, sizeof(sockaddr)) == -1){<br />
cout << "Connecting to backup server1: " << backupservers[0] << endl;<br />
ServerAddr1 = gethostbyname(backupservers[0]);<br />
structSock1.sin_family = AF_INET; <br />
structSock1.sin_port = htons(port); <br />
structSock1.sin_addr.s_addr = *((unsigned long*)ServerAddr1->h_addr_list[0]); <br />
memset(structSock.sin_zero, 0, 8); <br />
connect(dataSock, (sockaddr*)&structSock1, sizeof(sockaddr));<br />
}<br />
if(connect(dataSock, (sockaddr*)&structSock1, sizeof(sockaddr)) == -1){<br />
cout << "Connecting to backup server2: " << backupservers[1] << endl;<br />
ServerAddr1 = gethostbyname(backupservers[1]);<br />
structSock1.sin_family = AF_INET; <br />
structSock1.sin_port = htons(port); <br />
structSock1.sin_addr.s_addr = *((unsigned long*)ServerAddr1->h_addr_list[0]); <br />
memset(structSock.sin_zero, 0, 8); <br />
connect(dataSock, (sockaddr*)&structSock2, sizeof(sockaddr));<br />
}<br />
The idea here is that if the first connection doesnt work try another, and if that doesnt work try another. The first if function works fine. But the second executes the same time the first if block, which isnt what i want. I want it to wait until the if standards have been met, ie: no connection (-1). But its executing when its not wanted. This is really strange considering i took a short break to come back for one last test just to find out that it wasnt working. Any suggestions? Thanx in advance!
|
|
|
|
|
Assuming all your addresses are correct...
What happens if the second connect() call (of 4 you show)
succeeds? Then you try to connect again(?).
Take a look at your logic - why check for error on connect in some calls
and not on others?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|