Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Problem recovery matrix in C

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 07-05-2009
Member
 
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?

Reply With Quote
  #2  
Old 07-05-2009
Member
 
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?
Reply With Quote
  #3  
Old 07-05-2009
Member
 
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; 
              )
Reply With Quote
  #4  
Old 07-05-2009
Member
 
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).
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Problem recovery matrix in C"
Thread Thread Starter Forum Replies Last Post
New Matrix Movie (Matrix ReEntered) Vicious Off Topic Chat 8 08-02-2011 08:24 PM
Any fastest way to compute 3x3 Matrix inverse and Matrix multiplication? Logan.B Software Development 4 25-09-2010 05:11 PM
Problem writing creating recovery disc in Recovery Manager SajalSOFT Windows Software 6 11-09-2010 02:24 AM
Problem reading C++ matrix killerboy Software Development 4 14-11-2009 05:07 PM
Problem with Intel Matrix Storage HiSpeed Hardware Peripherals 3 19-10-2009 11:52 AM


All times are GMT +5.5. The time now is 03:45 PM.