Solved

I can only see 5 words in my list..

Posted on 2007-12-01
2
183 Views
Last Modified: 2010-04-21
I can only see 5 words in my list file. Is there something wrong with the code?

void Game::listWords()
{
      Game myGame;
      myGame.loadFile();

      cout << "\tThe following words in the file are: \n" << endl;

      for(int Loop = 0; Loop < Count - 1; Loop++)
      {
            cout << "\t" << Words[Loop] << "\n";
            if (++Loop > Count)
                  break;
            cout << "\t" << Words[Loop] << "\n";
            if (++Loop > Count)
                  break;
            cout << "\t" << Words[Loop] << "\n";
            if (++Loop > Count)
                  break;
            cout << "\t" << Words[Loop] << "\n";
            if (++Loop > Count)
                  break;
            cout << "\t" << Words[Loop] << "\n";
      }
}

0
Comment
Question by:jschmuff
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 20389315
If you initialize 'Count' to 0, that should be

      for(int Loop = 0; Loop < Count; Loop++)
         cout << "\t" << Words[Loop] << "\n";

That is all you need.
0
 

Author Closing Comment

by:jschmuff
ID: 31412135
perfect answer you are awesome.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now