Results 1 to 4 of 4

Thread: Problem recovery matrix in C

  1. #1
    Join Date
    Apr 2009
    Posts
    29

    Problem recovery matrix in C

    hi,
    I have created a calculator in C project for managing the tables ( 2-dimensional) which does addition,multiplication.But when I block (recovery of values to store in the matrix) it because I want to load the array from external text files. (I do not know if I am very clear ...)
    Here is the code for more info:
    Code:
     # include <stdio.h> 
      # include <stdlib.h> 
      # include <math.h> 
      # include <string.h> 
      # define COLUMNS 10 
      # define LINES 10 
    
    
      int main (int argc, char * argv []) 
      ( 
          FILE * file = NULL; 
          int character = 0, i = 0, j = 0; 
          int table [LINES] [COLUMNS]; 
          for (i = 0; i <LINES; i + +) 
          ( 
              for (j = 0 j <COLUMNS; j + +) 
              ( 
                  table [i] [j] ='0 '; 
              ) 
          ) 
          file = fopen ( "tableau.txt", "r"); 
          if (file! = NULL) 
          ( 
              / / Loop reading characters one at a 
    
              do 
              ( 
                  character = fgetc (file); / / On the bed 
                  if (character! = '|') 
                  ( 
                      table [j] [i] = character; 
                  ) 
                  else 
                  ( 
                      i + +; 
                  ) 
    
                  if (character! = 'n') 
                  ( 
                      table [j] [i] = character; 
                  ) 
                  else 
                  ( 
                      table [j] [i - 1] = table [j] [i]; 
                      j + +; 
                      i = 0; 
                  ) 
                  printf ( "% c", character) / * and displays the character (compare it: D) * / 
              ) While (character! = EOF) 
              for (i = 0; i <COLUMNS; i + +) 
              ( 
                  for (j = 0 j <LINES; j + +) 
                  ( 
                      printf ( "% ld \ n", table [j] [i]); / * Display the matrix plant ...*/ 
                  ) 
              ) 
              fclose (file); 
          ) 
      system ( "PAUSE"); 
      return 0; 
      )

    Here's my file structure table.txt:
    Citation: Matrix
    1 | 1 | 1 | 1
    2 | 2 | 2 | 2
    3 | 3 | 3 | 3
    4 | 4 | 4 | 4


    The file must be binary?

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Problem recovery matrix in C

    Code:
     int table [LINES] [COLUMNS];
    and (among others)

    Code:
    table [i] [j] ='0 ';

    characters stored in an array of int?

  3. #3
    Join Date
    Apr 2009
    Posts
    29

    Re: Problem recovery matrix in C

    I had not problem in the beginning because it was an array of char

    Code:
      table [i] [j] = 0;
    In addition, I put "cookies" and I notice that the picture is set to 0.

    Code:
     if (character! = '|') / / STATUS 1 
                  ( 
                      table [j] [i] = character; 
                  ) 
                  else / / 2 
                  ( 
                      i + +; 
                  ) 
    
                  if (character! = 'n') / / 3 
                  ( 
                      table [j] [i] = character; 
                  ) 
                  else / / 4 
                  ( 
                      table [j] [i - 1] = table [j] [i]; 
                      j + +; 
                      i = 0; 
                  )

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    Re: Problem recovery matrix in C

    In your program you store the return fgetc () int a (so far no problem but forget that this value is the equivalent of an ASCII character) and if the conditions are match in your table (at a given index).

Similar Threads

  1. New Matrix Movie (Matrix ReEntered)
    By Vicious in forum Off Topic Chat
    Replies: 8
    Last Post: 08-02-2011, 08:24 PM
  2. Replies: 4
    Last Post: 25-09-2010, 05:11 PM
  3. Problem writing creating recovery disc in Recovery Manager
    By SajalSOFT in forum Windows Software
    Replies: 6
    Last Post: 11-09-2010, 02:24 AM
  4. Problem reading C++ matrix
    By killerboy in forum Software Development
    Replies: 4
    Last Post: 14-11-2009, 05:07 PM
  5. Problem with Intel Matrix Storage
    By HiSpeed in forum Hardware Peripherals
    Replies: 3
    Last Post: 19-10-2009, 11:52 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,532,679.19968 seconds with 17 queries