Thread: ASCII input?

  1. #1

    ASCII input?


    I'm programming in C and I've used fopen to open my input file. My input file was written in ASCII so when I try to read in a byte or an int it inputs it as the ASCII value and not as the character... i.e in the file the number 0 will come into my buffer as it's unsigned 8 bit 48, how can I input the 0 as a 0? Is there a nicer function than fread to do this?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    You mean your file was written in text and you're trying to read it in binary? If all of the data is strings then fread should some extent, but if you want to read text easily you want to use fgets and then break it up however you want with sscanf. Also make sure that you're printing out the characters that you read with text functions such as putchar().

    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can someone help me with these errors please code included
    By geekrockergal in forum C Programming
    Replies: 7
    Last Post: 02-10-2009, 02:20 PM
  2. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  3. Structure and Linked List User Input Question
    By kevndale79 in forum C Programming
    Replies: 16
    Last Post: 10-05-2006, 11:09 AM
  4. Simple Console Input for Beginners
    By jlou in forum C++ Programming
    Replies: 0
    Last Post: 06-21-2005, 01:50 PM
  5. need help with some input
    By blindleaf in forum C Programming
    Replies: 2
    Last Post: 03-16-2003, 01:50 PM