Jump to content

Read from a file

- - - - -

  • Please log in to reply
4 replies to this topic

#1
vasil_9x

vasil_9x

    Newbie

  • Members
  • PipPip
  • 13 posts
I have a file and I want to read the information which is in it, buy I want to make the information be like an array (A[100][100]). How can I do it.

#2
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 889 posts
  • Location:::1
C or C++? Concept is the same, only other functions/methods are used.
A conclusion is where you got tired of thinking.
#define class struct    // All is public.

#3
vasil_9x

vasil_9x

    Newbie

  • Members
  • PipPip
  • 13 posts
C. Thanks.

#4
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 889 posts
  • Location:::1
You'll need a pointer to FILE structure, open it with fopen, check whether pointer is NULL (missing file, name mismatch) and then reading begins. You can read whole lines (to '\n' character) with fgets or you can read words (up to first white space) with fscanf. Also, when you're done don't forget to close the file.
A conclusion is where you got tired of thinking.
#define class struct    // All is public.

#5
vasil_9x

vasil_9x

    Newbie

  • Members
  • PipPip
  • 13 posts
How can I make the program recognize that the information in the file is matrix?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users