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.

Recommended Answers

All 2 Replies

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:

// wait for key press at end of console program

#include <iostream>

using namespace std;

void wait(); 

int main()
{
  // Your code here

  // C++
  cin.sync();  // purge any \n
  cin.get();   // console wait

  // or
  // clear the stream, purge any \n
  while (cin.get() != '\n')
    ;
  cin.get(); // wait

  // or
  // more complete
  while (std::cin.get(ch) && ch != '\n')
    ;
  cin.get();  // wait

  // or
  cin.ignore ( 1024, '\n' );
  cin.get(); // wait

  // or
  cin.get(); // trap loose \n
  cin.get(); // wait

  wait();    // write your own, for C++

  // system("PAUSE");  // wait, not portable

  // C
  // clear the stream
  while ((ch = getchar()) != '\n' && ch != EOF);
  getchar();  // for C, same caveat as cin.get()

  return 0;
}

// portable, need to declare prototype unless
// function precedes call
void wait()
{ 
  cout << "Press any key to continue ..."; 
  string z; 
  getline(cin,z); 
}

I am a little skittish posting in the C++ forum, since I have been kicked out of here unceremoniously in the past.

>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.

cin.ignore ( 1024, '\n' );
cin.get(); // wait

Magic numbers should be avoided:

#include <ios>
#include <limits>

cin.ignore ( numeric_limits<streamsize>::max(), '\n' );
cin.get(); // Wait
cin.get(); // trap loose \n
cin.get(); // wait

This only works if the only thing left in the stream is a newline.

cout << "Press any key to continue ..."; 
string z; 
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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.