Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: size of a 1-character file == 2

  1. #11
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    6,235
    Distro
    Xubuntu 17.10 Artful Aardvark

    Re: size of a 1-character file == 2

    By my understanding, the whole reason that getc returns an int rather than a char (which at first thought you might expect it to do) is so that it is then able to indicate end of file by returning a value that cannot be a valid char value. If it only returned char there would be no way to signal EOF.

  2. #12
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,281
    Distro
    Kubuntu

    Re: size of a 1-character file == 2

    Quote Originally Posted by ofnuts View Post
    Linefeed: is actually part of the file. Either you do something that your editor interprets as a line feed or it adds one by default at the end of the file
    You are correct; the line feed in Tubby's file was inserted by whatever means he used to create the file. Line feeds do not magically get included in a file unless the editor or other tool inserts them.

    Perhaps Tubby should create his text file using the following command:
    Code:
    echo -n "0123456789" > test.txt
    Note the -n option instructs echo not to generate a newline.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •