public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Arthur Schwarz <aschwarz1309@verizon.net>
To: gcc@gcc.gnu.org
Subject: cout Issue
Date: Tue, 12 May 2009 06:33:00 -0000	[thread overview]
Message-ID: <344634.73119.qm@web84007.mail.mud.yahoo.com> (raw)


Program and particulars below.

When line 27 is commented out, line 26 is output. When line 27 is not commented, line 26 is not output except that if x.file contains a line feed the null line line 26 & line 27 are output. If x.file does not contain a line feed, only line 27 is output.

Does the line feed have an effect on the 'cout <<' of line 26 of the program?

Note. The code is awful and this is an example.

art

g++-4 (GCC) 4.3.2 20080827 (beta) 2


x.cpp

      1 # include <ios>
      2 # include <iomanip>
      3 # include <fstream>
      4 # include <iostream>
      5 # include <sstream>
      6
      7 using namespace std;
      8
      9 ifstream  x("x.file", ios::in);
     10
     11 struct y {
     12   double a;
     13   double b;
     14 } yNot;
     15
     16 int main(int argc, char** argv) {
     17   char  Line[512];
     18   long  LineNo = 0;
     19   while ( !x.eof() ) {
     20      LineNo++;
     21      x.getline(Line, 512);
     22      istringstream Phfft(Line);
     23        yNot.a = -1;
     24        yNot.b = -2;
     25        Phfft >> yNot.a >> yNot.b;
     26        cout << setw(4) << LineNo << ": " << Line;
     27        cout << "   a:" << yNot.a << "  b:" << yNot.b;
     28      cout << endl;
     29   }
     30   return 0;
     31 }

x.file
1 2<lf>
<nada>

             reply	other threads:[~2009-05-12  4:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-12  6:33 Arthur Schwarz [this message]
2009-05-12  8:32 ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=344634.73119.qm@web84007.mail.mud.yahoo.com \
    --to=aschwarz1309@verizon.net \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).