~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I don't get it. :confused: eof() returns true if the eofbit is set, but the eofbit doesn't get set until you hit end of file while reading. Unless you test for end of file after the read, the order is wrong and you'll loop one too many times.

My bad, I should have been more explicit. Yes, I agree, feof( ) and eof( ) are not that great when compared to checking the stream state while reading files. But for small fixes I normally use:

#include <fstream>
#include <iostream>
#include <string>

int main()
{
  using namespace std;

  // Build a test file
  {
    ofstream os( "test.txt" );

    os << "12345";
  }

  // Test the test file :)
  ifstream is( "test.txt" );
  int loopCount = 0;
  char ch;

  while (1 ) {
    is.get( ch );
    if( is.eof() ) break ;
    ++loopCount;
    cout << ch << '\n';
  }

  cout << "Loop count: " << loopCount << '\n';
  getchar( ) ;
  return 0;
}

I'm surprised your little google groups didn't tell you that sos. Ha ha.

*sigh* Btw when are you turning 14 ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

you don't believe

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Wow, what a relief! I was so afraid I would get lots of criticism about the missing forum descriptions and last thread info. Thank you for the positive comments and encouragement!

Not so fast..... (there has to be a villian in the movie you know...)

With this new format I really don't get the point of keeping "Subcribe to a forum" feature. Previously it showed the last thread posted in that forum, but now it shows nothing, just the time last post was made ?

Smaller fonts and excessive use of gray colors make some things difficult to be seen.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

WHITE-feathered pandas are dining through lush bamboos, greedily.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

when you say const char strings are you refering to an array of chars?

Yes something of that sort, only thing to be taken care is that, the string literal should be constant.

const char name[] = "Daniweb" ;
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Congratulations Joey (I guess all call you by this name nowadays ;) ) !!!

I haven't read your blogs as such but I am sure you must have made it really good.

Keep praying that more people start writing blogs so that there really is a second time.....

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Are there any shortcuts I could have taken? I really want to learn!

Some points:
• Instead of representing GPA's with seperate const variables which clutter the code, you could have used [search]enum[/search] or enumerations which group the GPA's logically in a single unit. Something like:

enum GPA { F, D, C, B, A } ; // here F = 0, E = 1 and so on
// OR something like
enum GPA { A = 4, B = 3, C = 2, D = 1, F = 0 } ;

• Instead of representing grades and count using separate variables, you can use enumerations for representing the indices and make your task easier. For eg.

enum GRADES { A_grade, B_grade, C_grade, D_grade, F_grade } ; 
 // A_grade = 0 and so on

const double grade_arr[] = { 89.5, 79.5, 69.5, 59.5, 49.5 } ;

// now access the grades with something like grade_arr[ A_grade ]

enum COUNT { A_count, B_count, C_count, D_count, F_count } ;

int count_arr[ SZ ] ; // here SZ = 5, the number of grades

// now make changes to the count array as
count_arr[ A_count ] = 9 ;

• Don't forward declare variables until you plan on using them, it will save you from a lot of obscure bugs and hard to maintain code. In short declare the variables in the minimum scope you want them to persist and if possible just before the point of their use.

Hope you liked my post, I am trying to be nice you know....

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Nice one, though would be a nightmare for those who have vision problems....

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hello my friend, I have requested this thread to be moved to the appropriate forum so that you can get maximum help.

And btw, welcome to Daniweb. :D

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hey there buddy, welcome to Daniweb. :D

You are always welcome here... ;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You should avoid using the return value of eof() as the controlling condition for a loop. There are two reasons I know of to want to do this.

First, using the return value of eof() to terminate the loop is likely to cause a double counting of the last char in the file. If that char is a newline, then the double count will go unnoticed in your current code. But if the file terminates with an alphabetical char, it may, or may not, be counted twice. Inmy experience, trying to figure out why the code works appropriately sometimes and not others is probably the hardest bug to find.

That would be feof( ) you are talking about which returns zero only *after* the end of file is reached and not *when* the end of file is reached. eof( ) is actually good and returns a boolean value when the end of file is reached.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Is it really

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Sandpapers look very much like Flypapers.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

before yesterday. Come

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Ruffled-feathered pandas are eating through lush BAMBOOS, greedily.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

welsh -> Walsh

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Ruffled-feathered pandas are climbing through LUSH rainforests, lazily.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

creeks -> reeks

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

for discussing such

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

RUFFLED-feathered pandas are climbing through frozen oceans, lazily.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

brooms -> witches

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Heavily-armored pandas are climbing through frozen oceans, LAZILY.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

bandits -> goons

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Today is really

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

nothing happened at

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Rains can be a drizzle or a downpour.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

chaotic evil -> lawful good

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Something like this ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Heavily-armored sails are swimming through underground OCEANS, timidly.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

neutral -> alignment

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Heavily-armored sails are SWIMMING through underground rooms, effortlessly.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Heavily-ARMOURED snails are skimming through underground rooms, effortlessly.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

seratonin -> neurons

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

With the very notable exception of functional languages which use recursion as their way of creating an iterative procedure.

I guess I should have said the "languages in which I program"....

And I don't know for sure, but I don't think you can calculate the Ackermann function iteratively.

Though I am no expert on Mathematics, but the article says that Ackermann function can also be expressed iteratively and if it can be expressed iteratively, it can be solved iteratively.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Consider yourself lucky

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

synapse -> synaptic gap

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

calm and composed ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Heavily-shelled snails are crawling through underground rooms, EFFORTLESSLY

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Laundry service was Shakira's first album.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

HEAVILY-shelled snails are crawling through sticky rooms, easily.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You get island.

I put in jelly.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

RAM -> Physical memory

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Keycard ? Huh, what is a keycard ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

aliens who roam

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

step, so better

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Shabbily-tweaked SNAILS are running through sticky rooms, easily.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Methinks that this thread has really got out of hand.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

where no one

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

that what we

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

SHABBILY-tweaked noses are running through sticky hankies, easily.