delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/21/11:06:35

From: eyal DOT ben-david AT aks DOT com
To: dv1b AT hotmail DOT com
cc: djgpp AT delorie DOT com
Message-ID: <C225649E.0051216F.00@aks.com>
Date: Wed, 21 May 1997 18:04:36 +0300
Subject: Re: SUBJECT:(HELP ME)My Computer is Stupied or I am Stupied ???
(Too mush lines? its source code!)
Mime-Version: 1.0



Hello.

1.  put the line:   "cin.ignore(1024, '\n');"  before any cin.getline().
Also, replace every
     "fflush(stdin)" with the above statement.

2.  At the line of the problem (with getline), you read a string and then
parse it to find a number
     (by atoi). Why don't you use operator >>  ?

     cin.ignore(1024, '\n');
     if ( !(cin >> number) )
     {
           cerr << "failed to read number" << endl;
           HandleError();
     }

     In this approach you don't need to test  isitNumber. it is done for
you by cin

3.  Why don't you use ofstream and ifstream for file I/O ?. The mix between
stdio and iostream
     looks unnatural.

     The syntax of ofstream and ifstram is simple, and identical to
cin/cout.


4.  Good Luck

eyal.



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019