Thread: Problems putting a text file into a matrix.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    13

    Arrow Problems putting a text file into a matrix.

    Im trying to create the "game of life" but thus far have found great problems trying to input a text document into a matrix. Iv been trying to find a tutorial on the internet but none seem to answer the question, all i find is how to create an array or how to use a pointer.My code is as follows and is currently incomplete to run the program as I dont want the program written for me as its for my degree, I simply wish to know how to put the file "ref"(which comprises 1000, 1s or 0s) into the array "matrix"(10*10).
    Code:
    #include <stdio.h>
    int main()
    {
      int row, column;
      FILE *game;
      int *reference_ptr;
    
      game = fopen ("ref.txt", "r");
    
      if (game == NULL)
    {
          printf ("File could not be opened\n");
    }
      else
    {
          printf ("File opened!  Closing it now...\n");
          fclose (game);
          }
      reference_ptr=&game;
      int matrix[10][10] =
      {  
      *reference_ptr  
      };      
      }
    I get the returned error:"0019 ERROR:An object of type '<ptr><ptr>_file' cannot be assigned to an object of type '<ptr>int'"
    Last edited by warny_maelstrom; 01-20-2004 at 04:38 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  2. Replies: 19
    Last Post: 05-30-2007, 05:47 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM