Thread: Compling errors

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    79

    Compling errors

    Hello, here is my code below... I'm getting compiling errors as below. What is wrong?

    Code:
    cc1: warnings being treated as errors
    q1.c: In function 'GRAPHinit':
    q1.c:49: error: implicit declaration of function 'MATRIXint'
    q1.c:49: error: assignment makes pointer from integer without a cast
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    #define maxV 10
    
    int visited[maxV];
    
    typedef struct { int v; int w; } Edge;
    struct graph { int V; int E; int **adj; }; // adj [][] is a matrix.
    typedef struct graph *Graph;
    
    Graph GRAPHinit(int V);
    int **MATRIXinit(int r, int c, int val);
    int GRAPHpath(Graph G, int v, int w);
    int pathR(Graph G, int v, int w);
    
    int main(int argc, char *argv[]) {
    
    
    
       return 0;
    }
    
    int GRAPHpath(Graph G, int v, int w) {
       int t;
    
       for (t = 0; t < G -> V; t++) visited[t] = 0;
    
       return pathR(G, v, w);
    }
    
    int pathR(Graph G, int v, int w) {
       int t;
    
       if (v == w) return 1;
    
       visited[v] = 1;
    
       for (t = 0; t < G ->V; t++)
          if (G ->adj[v][t] == 1)
             if (visited[t] == 0)
                if (pathR(G, t, w)) return 1;
       return 0; //We will not come back to v. So, we will leave v as visited.
    }
    
    Graph GRAPHinit(int V) {
       Graph G = malloc(sizeof *G);
       G ->V = V; G->E = 0;
       G->adj = MATRIXint(V, V, 0);
       return G;
    }
    
    int **MATRIXinit(int r, int c, int val){
       int i, j;
       int **t = malloc( r * sizeof(int *) );
       for (i = 0; i < r; i++)
          t[i] = malloc(c * sizeof(int));
       for (i = 0; i < r; i++)
          for (j = 0; j < c; j++)
             t[i][j] = val;
       return t;
    }
    Thanks
    Last edited by Mini; 09-13-2010 at 03:58 PM.

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    MATRIXint != MATRIXinit

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    79
    Quote Originally Posted by rags_to_riches View Post
    MATRIXint != MATRIXinit
    Wow.. thank you so much... I feel so stupid now... Thank again!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  2. Unknown Errors in simple program
    By neandrake in forum C++ Programming
    Replies: 16
    Last Post: 04-06-2004, 02:57 PM
  3. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  4. Help me with these errors... :-(
    By major_small in forum C++ Programming
    Replies: 6
    Last Post: 09-07-2003, 08:18 PM
  5. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 06:51 PM