File program doubt

This is a discussion on File program doubt within the C++ Programming forums, part of the General Programming Boards category; But both results in processing last line twice, because getline return value is not checked before calling cout << Yes, ...

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,445
    But both results in processing last line twice, because getline return value is not checked before calling cout <<
    Yes, I pointed that out earlier; that's why they are only somewhat correct.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by chottachatri View Post
    Also you can write it as d:t1.txt as well as d:\t1.txt. It works perfectly fine on C as well as any C++ compiler.
    Only those intended for DOS/Windows/OS2 - "d:" does not have ANY meaning for paths in for example Linux.

    Also:
    "fstream.h"

    Is old style, new code should use:
    <fstream>

    [Even if you use old style headers, you should use angle-brackets, not quotes for system headers - and I presume you are not developing your own fstream implementation].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #18
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,473
    you can write it as d:t1.txt as well as d:\t1.txt
    These two have different meaning
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  4. #19
    Registered User
    Join Date
    Jan 2008
    Posts
    225
    Quote Originally Posted by vart View Post
    These two have different meaning
    Please explain me how? How are they different?

  5. #20
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by chottachatri View Post
    Please explain me how? How are they different?
    One is in the current directory on d:, the other one is in the root directory of d: - they are only the same for the case where current directory == root directory.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 11:39 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21