Thread: Reading text from file using structure.

  1. #1
    Registered User
    Join Date
    Feb 2012

    Reading text from file using structure.

    Hello! I wonder how can i read data from file into screen using structures.
    For example, if i have "file.txt" that consists data of name,age,location:
    Jason 34 Bern
    Mike 23 Ottawa
    Ted 35 Berlin

    Thank ya.

  2. #2
    Registered User
    Join Date
    Jul 2011
    read data from the file using fgets, then using strtok() function tokenize the read string and store into the structure(preferable structure array). Then print the contents of structure onto the screen

  3. #3
    Registered User ledow's Avatar
    Join Date
    Dec 2011
    Why do that when you can get someone else to do your homework, eh?

    - Compiler warnings are like "Bridge Out Ahead" warnings. DON'T just ignore them.
    - A compiler error is something SO stupid that the compiler genuinely can't carry on with its job. A compiler warning is the compiler saying "Well, that's bloody stupid but if you WANT to ignore me..." and carrying on.
    - The best debugging tool in the world is a bunch of printf()'s for everything important around the bits you think might be wrong.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading text file into a structure
    By jb1989 in forum C Programming
    Replies: 1
    Last Post: 12-13-2010, 12:17 PM
  2. Replies: 8
    Last Post: 05-05-2010, 02:43 PM
  3. Reading structure from file
    By nime in forum C++ Programming
    Replies: 7
    Last Post: 03-21-2010, 04:17 PM
  4. reading structure from file..??
    By CyC|OpS in forum C Programming
    Replies: 5
    Last Post: 04-07-2009, 05:28 AM
  5. from a text file to a structure ?
    By Intenz in forum C Programming
    Replies: 3
    Last Post: 12-30-2003, 01:32 PM