Projects in C++

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2005
Posts: 39
Reputation: comwizz is an unknown quantity at this point 
Solved Threads: 0
comwizz's Avatar
comwizz comwizz is offline Offline
Light Poster

Projects in C++

 
0
  #1
Mar 18th, 2006
He friends,
I would like to have some guidance over projects to take up in C++?
I would like to take up a challenging project . Also I have changed my compiler from turbo C++ to Dev C++ but i cannot figure out how the output can be seen ie the output window. Also how do we step into or step over .
Thanks for your help,
comwizz.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,052
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 935
Moderator
vegaseat's Avatar
vegaseat vegaseat is online now Online
DaniWeb's Hypocrite

Re: Projects in C++

 
0
  #2
Mar 18th, 2006
I don't want to step on any C++ toes, but there is a "Projects for Beginners" thread in the Python forum. Much of it is applicable to C++ programmers too. Take a look at:
http://www.daniweb.com/techtalkforums/thread32007.html

For Dev-C++ users there is a little handholding advice in this code snippet:
http://www.daniweb.com/code/snippet82.html

Also for console programs here are ways to make the console output wait for a key stroke, so you can read the output:
  1. // wait for key press at end of console program
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. void wait();
  8.  
  9. int main()
  10. {
  11. // Your code here
  12.  
  13. // C++
  14. cin.sync(); // purge any \n
  15. cin.get(); // console wait
  16.  
  17. // or
  18. // clear the stream, purge any \n
  19. while (cin.get() != '\n')
  20. ;
  21. cin.get(); // wait
  22.  
  23. // or
  24. // more complete
  25. while (std::cin.get(ch) && ch != '\n')
  26. ;
  27. cin.get(); // wait
  28.  
  29. // or
  30. cin.ignore ( 1024, '\n' );
  31. cin.get(); // wait
  32.  
  33. // or
  34. cin.get(); // trap loose \n
  35. cin.get(); // wait
  36.  
  37. wait(); // write your own, for C++
  38.  
  39. // system("PAUSE"); // wait, not portable
  40.  
  41. // C
  42. // clear the stream
  43. while ((ch = getchar()) != '\n' && ch != EOF);
  44. getchar(); // for C, same caveat as cin.get()
  45.  
  46. return 0;
  47. }
  48.  
  49. // portable, need to declare prototype unless
  50. // function precedes call
  51. void wait()
  52. {
  53. cout << "Press any key to continue ...";
  54. string z;
  55. getline(cin,z);
  56. }
I am a little skittish posting in the C++ forum, since I have been kicked out of here unceremoniously in the past.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,748
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 739
Team Colleague
Narue's Avatar
Narue Narue is online now Online
Code Goddess

Re: Projects in C++

 
0
  #3
Mar 18th, 2006
>cin.sync(); // purge any \n
This non-portable. From a standard perspective, it's also nonsensical for sync to discard the contents of the buffer. I've discussed it at length here.
  1. cin.ignore ( 1024, '\n' );
  2. cin.get(); // wait
Magic numbers should be avoided:
  1. #include <ios>
  2. #include <limits>
  3.  
  4. cin.ignore ( numeric_limits<streamsize>::max(), '\n' );
  5. cin.get(); // Wait
  1. cin.get(); // trap loose \n
  2. cin.get(); // wait
This only works if the only thing left in the stream is a newline.
  1. cout << "Press any key to continue ...";
  2. string z;
  3. getline(cin,z);
That's seriously overkill, and the prompt is misleading because getline is line oriented. You can hit any key, but unless that key is Enter, nothing will happen.

>I am a little skittish posting in the C++ forum, since I have been kicked out of here unceremoniously in the past.
I don't recall you being "kicked out". Can you link to the offending thread?
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC