From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30992 invoked by alias); 10 Apr 2003 12:26:33 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 30985 invoked from network); 10 Apr 2003 12:26:32 -0000 Received: from unknown (HELO smtp-relay-2.adobe.com) (192.150.11.2) by sources.redhat.com with SMTP; 10 Apr 2003 12:26:32 -0000 Received: from inner-relay-1.corp.adobe.com (inner-relay-1 [153.32.1.51]) by smtp-relay-2.adobe.com (8.12.9/8.12.9) with ESMTP id h3ACQU0w006032 for ; Thu, 10 Apr 2003 05:26:31 -0700 (PDT) Received: from iplan-mn.corp.adobe.com (iplan-mn.corp.adobe.com [130.248.25.5]) by inner-relay-1.corp.adobe.com (8.12.3/8.12.3) with ESMTP id h3ACQPVf028470 for ; Thu, 10 Apr 2003 05:26:25 -0700 (PDT) Received: from [130.248.25.184] ([153.32.12.150]) by iplan-mn.corp.adobe.com (Netscape Messaging Server 4.15 mn Jul 11 2001 16:32:57) with ESMTP id HD4NW000.62U; Thu, 10 Apr 2003 07:26:24 -0500 User-Agent: Microsoft-Entourage/10.0.0.1331 Date: Thu, 10 Apr 2003 12:26:00 -0000 Subject: Re: Fgets is not working on linux/gcc3.2.1 From: John Love-Jensen To: Ajay Bansal , , Message-ID: In-Reply-To: <2B721C6525F0D411B1E900B0D0226BDD027DCC6D@mohmsg01.ad.infosys.com> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-SW-Source: 2003-04/txt/msg00123.txt.bz2 Hi Ajay, Why not do it C++ style, instead of co-mingling C and C++ styles? Sincerely, --Eljay PS: your data-type Hungarian notation is incorrect. I strongly suggest that you avoid date-type Hungarian notation, unless you are going to be meticulously accurate. (Otherwise it contributes to code obfuscation.) PPS: I also recommend on "using" the particular item in the other namespace, instead of pulling in the whole namespace. PPPS: I also recommend using C++ headers, instead of pulling in C headers into your C++ code. (i.e., and .) --------------------- #include using std::cout; using std::endl; #include using std:: #include using std::string; // #include -- not needed. // #include -- not needed. int main() { string fileName("/tmp/log.txt"); string line; ifstream file(fileName.c_str()); int lineNumber = 0; while (getline(file, line)) { ++lineNumber; cout << "Line " << lineNumber << " read is : " << line << endl; } return 0; }