Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: How to use fgetc() with Teensy?

  1. #1
    Junior Member
    Join Date
    Aug 2023
    Posts
    12

    How to use fgetc() with Teensy?

    How can I use like this code with teensy?

    Code:
    ch = getc(in_file);
      /*convert the one digit integer currently represented as a character to
        an integer(48 == '0')*/
    
      while(getc(in_file) != '\n');             /* skip to end of line*/
    
      while (getc(in_file) == '#')              /* skip comment lines */
      {
        while (getc(in_file) != '\n');          /* skip to end of comment line */
      }

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    2,017
    Are you asking how to read characters from a file (if so which library are you using?), or more generally how to do ad-hoc parsing of a stream/file?

    I note that code is broken, for instance:
    Code:
      while(getc(in_file) != '\n');
    Will loop forever at the end of a file...

Posting Permissions

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