Problems Accessing Matrix

This is a discussion on Problems Accessing Matrix within the C Programming forums, part of the General Programming Boards category; Guys Im having a hard time generating a dinamically allocated matrix, Im trying to implement minimum square method to solve ...

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    277

    Problems Accessing Matrix

    Guys Im having a hard time generating a dinamically allocated matrix, Im trying to implement minimum square method to solve linear systems, I need to load an array of points from a file(what I do properly),
    for an array like
    x y
    1 2
    2 3.4
    3 5.6

    I need to load it on a matrix then generate 2 more matrixes, one is like

    |sum_of_numeber_of_elements sum_of_x_coordenates |
    |sum_of_x_coordenates sum_of_pow(x_coordenates,2) |

    the other is
    |sum of y |
    |sum of x*y|

    this configures a linear system Ax = b
    better description can be found here http://img46.echo.cx/my.php?image=screenshot13ud.png
    all the problem is Im not beeig able to access the first matrix I created to make the sums, once it is done my work is finished since my gaussian elimination works.

    Code:
    #include<stdlib.h>
    #include<stdio.h>
    #include<string.h>
    #include<math.h>
     
    #define MODULO(x) (x>=0 ? x : (-1) * x)
    #define CONSTID 2 
    
    int n;                        // dimensão do sistema linear
    char *vetPts = "pontos.dat";// nome do arquivo com o vetor de aproximação inicial
     
    void carregaPontos(char *arq, int n, long double ***matPts);
    void resolveEGauss(int n, long double **mat, long double *y);
    void mostraMat(int n, long double **mat);
    void geraMatrizElem(int gPol, int n, double *x, double **matElem);
    void geraVetorInd(int gPol, int m, double *x, double* y, double* vec);
    double somatorioIndependentes(int ini, int fim,int gX, double *x, double* y);
    double somatorioGrau(int ini, int fim, int exp, double* x);
     
    long double **matPts; //Eu vou gerar uma matriz s pra carregar os pontos do arquivo
    
    long double **matElem; //essa matriz aqui recebe os pontos j somados e elevados na n
     
    int main(){
        int n;
        int gPol;
        
    	printf("Informe o numero de pontos n = ");
    	scanf("%d", &n);
    	printf("Informe o grau do polinomio");
    	scanf("%d", &gPol);
    	carregaPontos(vetPts, n, &matPts);
    	mostraMat(n, matPts);
    	//geraMatrizElem(gPol, n, *x, matPts);
        return 0;    
     
    }
    
    
    
    /*read the points from the file and store them into a  xy array*/
    void carregaPontos(char *arq, int n, long double ***matPts)
    {
         int  i,j;
         float lido;
         FILE *fp;
         *matPts = (long double **) calloc(n, sizeof(long double *));
     
         fp=fopen(arq,"r");
         		for(i=0;i<n;i++)
         		{
            	(*matPts)[i] = (long double *) calloc(CONSTID,sizeof(long double));
    			
    			 if((*matPts)[i] == NULL) { 
    				printf("Error while allocating");
    			}
    
    		for(j=0;j<CONSTID;j++)
            		{
               		fscanf(fp,"%f ",&lido);
    			//printf("%f \n", lido);
               		(*matPts)[i][j] = lido;
    			}
         		}
         fclose(fp);
    }
     
    //This should generate the matrix of elements but is not working
    /*void geraMatrizElem(int gPol, int n, double *x, double **matElem){
         int i, j;
         
         matElem = calloc(n, sizeof(long double *));
    		for(i=0;i<n;i++)
         		{
            	  matElem[i] = calloc(n,sizeof(long double));
    			
    			 if(matElem[i] == NULL) { 
    				printf("Error while allocating");
    			 }
         		}
           for (i=0;i<gPol;i++){
           		for (j=0;j<gPol;j++){
            		matElem[i][j] = somatorioGrau(0,n,i+j,x);
             	}
         	}
    }
    */ 
     
    /*This function generates the vector of independent elements
    void geraVetorInd(int gPol, int m, double *x, double* y, double* vec){
     
         int i;
         for (i = 0;i<gPol;i++){
             vec[i] = somatorioIndependentes(0,m,i,x,y);
         }
    }
    */
    /*make the sums of the independent elements vector*/
    double somatorioIndependentes(int ini, int fim,int gX, double *x, double* y){
           int i = 0;
           double result=0;
           for (i=ini;i<=fim;i++){
               result += (pow(x[i],gX)*y[i]);
           }
     
           return result;
    }
     
    /*make the sums of the main matrix
    double somatorioGrau(int ini, int fim, int exp, double *x){
           int i;
           double result = 0;
           for (i=ini;i<=fim;i++){
               result+=pow(x[i],exp);
           }
           return result;
    }
    
    /*Testing function just to assure the matrix is there is prints the matrix created with the points read from inpout*/
    void mostraMat(int n, long double **mat){
         int i,j;
         for(i=0; i<n; i++)
           {
            for(j=0; j<CONSTID; j++)
              printf("%03.2f ", (float)mat[i][j]);
            printf("\n");
           }
         printf("\n");
    }
    
     
     
    /*Given a matrix **mat its dimension n and a vector *y solves the system Ax = b using Gaussian Elimination */
    void resolveEGauss(int n, long double **mat, long double *y)
    {
         int k, i, j;          // para uso em fors
         int index;            // ..ndice da linha que tem o pivô
         long double maior;    // pivô da coluna
         long double fator;    // fator multiplicativo para zerar os elementos abaixo do pivô
         long double temp;     // variável auxiliar para trocar os elementos de posição em y
         long double *lmaior; // ponteiro para a linha indexada por index
         long double x[n];     // vetor com o resultado
     
         for(k=0; k<n; k++) // percorre todas as colunas
         {
         maior = 0;
             for(i=k; i<n; i++)  // encontra o maior da coluna k
             {
                 if(MODULO(maior)<MODULO(mat[i][k]))
                 {
                     maior = mat[i][k];
                     index = i;
                 }
             }
             if(maior == 0)
             {
                 printf("\nEl. de Gauss: MATRIZ SINGULAR!\n");
                 return;
             }
             lmaior = mat[index];  // the biggest element must be the pivot
             mat[index] = mat[k];
             mat[k] = lmaior;
             temp = y[index];      // also for independent terms
             y[index] = y[k];
             y[k] = temp;
             for(i=k+1; i<n; i++)  // eliminates the elements under the pivot
             {
                 fator = mat[i][k]/mat[k][k];
                 y[i] = y[i] - fator*y[k];
                 for(j=k; j<n; j++)
                 {
                     mat[i][j] = mat[i][j] - fator*mat[k][j];
                 }
             }
         }
         // retrosubstituition
         for(k=n-1; k>=0; k--)
         {
             x[k] = y[k];       
             for(i=k+1; i<n; i++)
             {
                 x[k] = x[k] - mat[k][i]*x[i];
             }
             x[k] = x[k]/mat[k][k];
         }
         printf("Resposta obtida pela Eliminacao de Gauss com Pivoteamento:\n");
         for(j=0; j<n; j++)
             printf("\nx%d = %f", j+1, (float)x[j]);
         printf("\n\n");
    }
    If you can point me some suggestion I will be very grateful, og I cant turn the elements into structs sine it would generate the necessity of modification into the gaussian elimination system and it is something out of question for now since it works perfectly. Well resuming I need to find out how make a pointer acess my matrix the create the sums and store them into 2 other matrixes. yes it is homework but I dont want you to do it for me, just to point me a way to make these 2 functions work. Thanks a lot.
    Last edited by Maragato; 05-08-2005 at 02:32 PM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    > //This should generate the matrix of elements but is not working
    It needs to be written in the same way (and called in the same way) as carregaPontos()
    That is, called with &mypointer, and have *** parameter type.

    PS
    malloc doesn't need casting in C, see the FAQ
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    277
    Quote Originally Posted by Salem
    > //This should generate the matrix of elements but is not working
    It needs to be written in the same way (and called in the same way) as carregaPontos()
    That is, called with &mypointer, and have *** parameter type.

    PS
    malloc doesn't need casting in C, see the FAQ
    Thanks a lot by the tips, the casts were done by a friend of mine I know calloc returns void

    Im trying something like this
    Code:
    void GeraMatrizElem(int n, long double ***matPts, long double ***matElem){
    	int i, j;
         	matElem = calloc(n, sizeof(long double *));
    		for(i=0;i<n;i++)
         		{
            	  matElem[i] = calloc(n,sizeof(long double));
    			
    			 if(matElem[i] == NULL) { 
    				printf("Error while allocating");
    			 }
         		}
           for (i=0;i<n;i =i+2){
           		for (j = 0; j < CONSTID; j++){
           			matElem[i][j] = pow(&matPts[i][YPOS],i+j);	
                     }
           }
    }
    But the argument for pow is obviusly wrong, but again thanks a lot for givin me a direction.

  4. #4
    Registered User
    Join Date
    Jun 2004
    Posts
    277
    I think things improved in the right direction here:
    Code:
    #include<stdlib.h>
    #include<stdio.h>
    #include<string.h>
    #include<math.h>
     
    #define MODULO(x) (x>=0 ? x : (-1) * x)
    #define CONSTCOL 1 
    #define YPOS	 0
    #define CONSTID  2
    
    int n;                        // dimensão do sistema linear
    char *vetPts = "pontos.dat";// nome do arquivo com o vetor de aproximação inicial
     
    void carregaPontos(char *arq, int n, double ***matPts);
    void resolveEGauss(int n, double **mat, double *y);
    void mostraMat(int n, double **mat);
    void geraMatrizElem(int n, double ***matPts, double ***matElem);
    void geraVetorInd(int gPol, int m, double *x, double* y, double* vec);
    double somatorioIndependentes(int ini, int fim,int gX, double *x, double* y);
    double somatorioGrau(int ini, int fim, int exp, double* x);
     
    double **matPts; //Eu vou gerar uma matriz s pra carregar os pontos do arquivo
    
    double **matElem; //essa matriz aqui recebe os pontos j somados e elevados na n
     
    int main(){
        int n;
        int gPol;
        
    	printf("Informe o numero de pontos n: ");
    	scanf("%d", &n);
    	printf("Informe o grau do polinomio: ");
    	scanf("%d", &gPol);
    	carregaPontos(vetPts, n, &matPts);
    	mostraMat(n, matPts);
    	geraMatrizElem(n, &matElem, &matPts);
        return 0;    
     
    }
    
    
    
    /*read the points from the file and store them into a  xy array*/
    void carregaPontos(char *arq, int n, double ***matPts)
    {
         int  i,j;
         float lido;
         FILE *fp;
         *matPts = calloc(n, sizeof(double *));
     
         fp=fopen(arq,"r");
         		for(i=0;i<n;i++)
         		{
            	(*matPts)[i] = (double *) calloc(CONSTID,sizeof(double));
    			
    			 if((*matPts)[i] == NULL) { 
    				printf("Error while allocating");
    			}
    
    		for(j=0;j<CONSTID;j++)
            		{
               		fscanf(fp,"%f ",&lido);
    			//printf("%f \n", lido);
               		(*matPts)[i][j] = lido;
    			}
         		}
         fclose(fp);
    }
    
    
     
    //This should generate the matrix of elements but is not working
    /*void geraMatrizElem(int gPol, int n, double *x, double **matElem){
         int i, j;
         
         matElem = calloc(n, sizeof(double *));
    		for(i=0;i<n;i++)
         		{
            	  matElem[i] = calloc(n,sizeof(double));
    			
    			 if(matElem[i] == NULL) { 
    				printf("Error while allocating");
    			 }
         		}
           for (i=0;i<gPol;i++){
           		for (j=0;j<gPol;j++){
            		matElem[i][j] = somatorioGrau(0,n,i+j,x);
             	}
         	}
    }
    */ 
     
    /*This function generates the vector of independent elements
    void geraVetorInd(int gPol, int m, double *x, double* y, double* vec){
     
         int i;
         for (i = 0;i<gPol;i++){
             vec[i] = somatorioIndependentes(0,m,i,x,y);
         }
    }
    */
    /*make the sums of the independent elements vector*/
    
    /*Samir eu refiz essa funo agora t bem mais perto de dar certo tipo a explicao e a mesma logica do anterior, mas eu mo to conseguindo acessar os elementos da matriz original, mas isso  um problema de ponteiros vale a mesma lgica de soma dos pontos, talvez isso esteja errado vou rever mais aqui*/
    void geraMatrizElem(int n, double ***matPts, double ***matElem){
    	int i, j;
         	matElem = calloc(n, sizeof(double *));
    		for(i=0;i<n;i++)
         		{
            	  matElem[i] = calloc(CONSTCOL,sizeof(double));
    			
    			 if(matElem[i] == NULL) { 
    				printf("Error while allocating");
    			 }
         		}
           for (i=0;i<n;i++){
           		for (j = 0; j < n; j++){
           			//matElem[i][j] = pow((matPts)[i][YPOS],i+j);	
                     (*matElem)[i][j] = pow((*matPts)[i][YPOS],i+j);
    		 printf("%f",matElem[i][j]);
    		 }
           }
    }
    
    
    /*double somatorioIndependentes(int ini, int fim,int gX, double *x, double* y){
           int i = 0;
           double result=0;
           
           for (i=ini;i<=fim;i++){
               result += (pow(x[i],gX)*y[i]);
           }
     
           return result;
    }
     */
     
    /*make the sums of the main matrix
    double somatorioGrau(int ini, int fim, int exp, double *x){
           int i;
           double result = 0;
           for (i=ini;i<=fim;i++){
               result+=pow(x[i],exp);
           }
           return result;
    }
    
    Testing function just to assure the matrix is there is prints the matrix created with the points read from inpout*/
    void mostraMat(int n, double **mat){
         int i,j;
         for(i=0; i<n; i++)
           {
            for(j=0; j<CONSTID; j++)
              printf("%03.2f ", (float)mat[i][j]);
            printf("\n");
           }
         printf("\n");
    }
    
     
     
    /*Given a matrix **mat its dimension n and a vector *y solves the system Ax = b using Gaussian Elimination */
    void resolveEGauss(int n, double **mat, double *y)
    {
         int k, i, j;          // para uso em fors
         int index;            // ..ndice da linha que tem o pivô
         double maior;    // pivô da coluna
         double fator;    // fator multiplicativo para zerar os elementos abaixo do pivô
         double temp;     // variável auxiliar para trocar os elementos de posição em y
         double *lmaior; // ponteiro para a linha indexada por index
         double x[n];     // vetor com o resultado
     
         for(k=0; k<n; k++) // percorre todas as colunas
         {
         maior = 0;
             for(i=k; i<n; i++)  // encontra o maior da coluna k
             {
                 if(MODULO(maior)<MODULO(mat[i][k]))
                 {
                     maior = mat[i][k];
                     index = i;
                 }
             }
             if(maior == 0)
             {
                 printf("\nEl. de Gauss: MATRIZ SINGULAR!\n");
                 return;
             }
             lmaior = mat[index];  // Troca linhas para o maior elemento ser pivô
             mat[index] = mat[k];
             mat[k] = lmaior;
             temp = y[index];      // Faz o mesmo no vetor de termos independentes
             y[index] = y[k];
             y[k] = temp;
             for(i=k+1; i<n; i++)  // Zera os elementos abaixo do pivô
             {
                 fator = mat[i][k]/mat[k][k];
                 y[i] = y[i] - fator*y[k];
                 for(j=k; j<n; j++)
                 {
                     mat[i][j] = mat[i][j] - fator*mat[k][j];
                 }
             }
         }
         // Para finalizar, faz-se a retrosubstituição
         for(k=n-1; k>=0; k--)
         {
             x[k] = y[k];       
             for(i=k+1; i<n; i++)
             {
                 x[k] = x[k] - mat[k][i]*x[i];
             }
             x[k] = x[k]/mat[k][k];
         }
         printf("Resposta obtida pela Eliminacao de Gauss com Pivoteamento:\n");
         for(j=0; j<n; j++)
             printf("\nx%d = %f", j+1, (float)x[j]);
         printf("\n\n");
    }
    But now I have a segfault

  5. #5
    Registered User
    Join Date
    Jun 2004
    Posts
    277
    And ive located the segfault spot but I dont know how to fix, trhe line is commnted
    Code:
    include<stdlib.h>
    #include<stdio.h>
    #include<string.h>
    #include<math.h>
     
    #define MODULO(x) (x>=0 ? x : (-1) * x)
    #define CONSTCOL 1 
    #define YPOS	 0
    #define CONSTID  2
    
    int n;                        // dimensão do sistema linear
    char *vetPts = "pontos.dat";// nome do arquivo com o vetor de aproximação inicial
     
    void carregaPontos(char *arq, int n, double ***matPts);
    void resolveEGauss(int n, double **mat, double *y);
    void mostraMat(int n, double **mat);
    void geraMatrizElem(int n, double ***matPts, double ***matElem);
    void geraVetorInd(int gPol, int m, double *x, double* y, double* vec);
    double somatorioIndependentes(int ini, int fim,int gX, double *x, double* y);
    double somatorioGrau(int ini, int fim, int exp, double* x);
     
    double **matPts; //Eu vou gerar uma matriz s pra carregar os pontos do arquivo
    
    double **matElem; //essa matriz aqui recebe os pontos j somados e elevados na n
     
    int main(){
        int n;
        int gPol;
        
    	printf("Informe o numero de pontos n: ");
    	scanf("%d", &n);
    	printf("Informe o grau do polinomio: ");
    	scanf("%d", &gPol);
    	carregaPontos(vetPts, n, &matPts);
    	mostraMat(n, matPts);
    	geraMatrizElem(n, &matElem, &matPts);
        return 0;    
     
    }
    
    
    
    /*read the points from the file and store them into a  xy array*/
    void carregaPontos(char *arq, int n, double ***matPts)
    {
         int  i,j;
         float lido;
         FILE *fp;
         *matPts = calloc(n, sizeof(double **));
     
         fp=fopen(arq,"r");
         		for(i=0;i<n;i++)
         		{
            	(*matPts)[i] = (double *) calloc(CONSTID,sizeof(double));
    			
    			 if((*matPts)[i] == NULL) { 
    				printf("Error while allocating");
    			}
    
    		for(j=0;j<CONSTID;j++)
            		{
               		fscanf(fp,"%f ",&lido);
    			//printf("%f \n", lido);
               		(*matPts)[i][j] = lido;
    			}
         		}
         fclose(fp);
    }
    
    
     
    //This should generate the matrix of elements but is not working
    /*void geraMatrizElem(int gPol, int n, double *x, double **matElem){
         int i, j;
         
         matElem = calloc(n, sizeof(double *));
    		for(i=0;i<n;i++)
         		{
            	  matElem[i] = calloc(n,sizeof(double));
    			
    			 if(matElem[i] == NULL) { 
    				printf("Error while allocating");
    			 }
         		}
           for (i=0;i<gPol;i++){
           		for (j=0;j<gPol;j++){
            		matElem[i][j] = somatorioGrau(0,n,i+j,x);
             	}
         	}
    }
    */ 
     
    /*This function generates the vector of independent elements
    void geraVetorInd(int gPol, int m, double *x, double* y, double* vec){
     
         int i;
         for (i = 0;i<gPol;i++){
             vec[i] = somatorioIndependentes(0,m,i,x,y);
         }
    }
    */
    /*make the sums of the independent elements vector*/
    
    /*Samir eu refiz essa funo agora t bem mais perto de dar certo tipo a explicao e a mesma logica do anterior, mas eu mo to conseguindo acessar os elementos da matriz original, mas isso  um problema de ponteiros vale a mesma lgica de soma dos pontos, talvez isso esteja errado vou rever mais aqui*/
    void geraMatrizElem(int n, double ***matPts, double ***matElem){
    	int i, j;
    	float k, l;
         	matElem = calloc(n, sizeof(double *));
    		for(i=0;i<n;i++)
         		{
            	  matElem[i] = calloc(CONSTCOL,sizeof(double));
    			
    			 if(matElem[i] == NULL) { 
    				printf("Error while allocating");
    			 }
         		}
           for (i = 0;i<n;i++){
           		for (j = 0; j < n; j++){
    		k = i;
    		l = j;
           			//matElem[i][j] = pow((matPts)[i][YPOS],i+j);	
                     //matElem[i][j] = pow((matPts[i][YPOS],k+l);// This is broken
    		 printf("%f",matElem[i][j]);
    		 }
           }
    }
    
    
    /*double somatorioIndependentes(int ini, int fim,int gX, double *x, double* y){
           int i = 0;
           double result=0;
           
           for (i=ini;i<=fim;i++){
               result += (pow(x[i],gX)*y[i]);
           }
     
           return result;
    }
     */
     
    /*make the sums of the main matrix
    double somatorioGrau(int ini, int fim, int exp, double *x){
           int i;
           double result = 0;
           for (i=ini;i<=fim;i++){
               result+=pow(x[i],exp);
           }
           return result;
    }
    
    Testing function just to assure the matrix is there is prints the matrix created with the points read from inpout*/
    void mostraMat(int n, double **mat){
         int i,j;
         for(i=0; i<n; i++)
           {
            for(j=0; j<CONSTID; j++)
              printf("%03.2f ", (float)mat[i][j]);
            printf("\n");
           }
         printf("\n");
    }
    
     
     
    /*Given a matrix **mat its dimension n and a vector *y solves the system Ax = b using Gaussian Elimination */
    void resolveEGauss(int n, double **mat, double *y)
    {
         int k, i, j;          // para uso em fors
         int index;            // ..ndice da linha que tem o pivô
         double maior;    // pivô da coluna
         double fator;    // fator multiplicativo para zerar os elementos abaixo do pivô
         double temp;     // variável auxiliar para trocar os elementos de posição em y
         double *lmaior; // ponteiro para a linha indexada por index
         double x[n];     // vetor com o resultado
     
         for(k=0; k<n; k++) // percorre todas as colunas
         {
         maior = 0;
             for(i=k; i<n; i++)  // encontra o maior da coluna k
             {
                 if(MODULO(maior)<MODULO(mat[i][k]))
                 {
                     maior = mat[i][k];
                     index = i;
                 }
             }
             if(maior == 0)
             {
                 printf("\nEl. de Gauss: MATRIZ SINGULAR!\n");
                 return;
             }
             lmaior = mat[index];  // Troca linhas para o maior elemento ser pivô
             mat[index] = mat[k];
             mat[k] = lmaior;
             temp = y[index];      // Faz o mesmo no vetor de termos independentes
             y[index] = y[k];
             y[k] = temp;
             for(i=k+1; i<n; i++)  // Zera os elementos abaixo do pivô
             {
                 fator = mat[i][k]/mat[k][k];
                 y[i] = y[i] - fator*y[k];
                 for(j=k; j<n; j++)
                 {
                     mat[i][j] = mat[i][j] - fator*mat[k][j];
                 }
             }
         }
         // Para finalizar, faz-se a retrosubstituição
         for(k=n-1; k>=0; k--)
         {
             x[k] = y[k];       
             for(i=k+1; i<n; i++)
             {
                 x[k] = x[k] - mat[k][i]*x[i];
             }
             x[k] = x[k]/mat[k][k];
         }
         printf("Resposta obtida pela Eliminacao de Gauss com Pivoteamento:\n");
         for(j=0; j<n; j++)
             printf("\nx%d = %f", j+1, (float)x[j]);
         printf("\n\n");
    }

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    > //matElem[i][j] = pow((matPts[i][YPOS],k+l);// This is broken
    Do it like in carregaPontos

    (*matElem)[i][j] = pow(((*matPts)[i][YPOS],k+l);

    Both are *** pointers, so you need the (*foo) just to remove one level of indirection, then you use the [i][j] to access the array proper.

    You're doing pretty well, it takes people a while to get the (*foo) notation sorted out
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Jun 2004
    Posts
    277
    Quote Originally Posted by Salem
    > //matElem[i][j] = pow((matPts[i][YPOS],k+l);// This is broken
    Do it like in carregaPontos

    (*matElem)[i][j] = pow(((*matPts)[i][YPOS],k+l);

    Both are *** pointers, so you need the (*foo) just to remove one level of indirection, then you use the [i][j] to access the array proper.

    You're doing pretty well, it takes people a while to get the (*foo) notation sorted out
    Ive finished it! Weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 4 days of work! The source isnt on my home PC but in my uni so I will post it later Thanks a lot for all the suggestions!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C program - inverse of a matrix
    By chaugh in forum C Programming
    Replies: 4
    Last Post: 01-18-2010, 10:00 PM
  2. Problems accessing logged on user via System.Security
    By conor20_ie in forum C# Programming
    Replies: 5
    Last Post: 11-16-2007, 06:52 AM
  3. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  4. Simple operator overloading issue
    By Desolation in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2007, 08:56 PM
  5. Weird errors.
    By Desolation in forum C++ Programming
    Replies: 20
    Last Post: 05-09-2007, 01:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21