Can't find problem

This is a discussion on Can't find problem within the C Programming forums, part of the General Programming Boards category; I would be most gratefull if someone could tell me what is wrong. The error is '"<Unknown>' : missing subscript". ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    3

    Can't find problem

    I would be most gratefull if someone could tell me what is wrong. The error is '"<Unknown>' : missing subscript". The arrow points to the function. Please help

    #include<stdio.h>

    char Prim(char edgeArray1[], char edgeArray2[], int weightArray[], char nodeArray[], char startPointArray[], char endPointArray[], int weightVisitArray[], int adjacencyArray[]);


    int main()
    {
    int shortestEdgeLength = 999;
    int shortestEdgeIndex = 0;
    char startPoint = 'a';
    int index = 9, index2 = 0, m = 14,n = 9;
    //An array to hold the start point of each edge
    char edgeArray1[9];
    //An array to hold the end point of each edge
    char edgeArray2[9];
    //An array to hold the Weights of the Edges
    int weightArray[9];
    //An array to hold the adacency table
    int adjacencyArray[9][9];
    char startPointArray[9];
    char nodeArray[9];
    //An array to hold the end vertice of visited edges
    char endPointArray[9];
    //An array to hold the weights of visited edges
    int weightVisitArray[9];

    .
    . The stuff in this gap reads the information in an array
    .
    startPointArray[0] = startPoint;
    //visited points
    nodeArray[0] = startPoint;
    printf("\n");
    //Call the Prim method to find minimum spanning tree
    Prim(edgeArray1, edgeArray2, weightArray, nodeArray, startPointArray, endPointArray, weightVisitArray, adjacencyArray);

    }
    //Method to find minimum spanning tree using Prim's Algorithm

    char Prim(char edgeArray1[], char edgeArray2[], int weightArray[], char nodeArray[],
    char startPointArray[], char endPointArray[], int weightVisitArray[], int adjacencyArray[][])


    Thanks
    b-ref

  2. #2
    Unregistered
    Guest
    In your Prim prototype, you have:

    char Prim(char edgeArray1[], char edgeArray2[], int weightArray[], char nodeArray[], char startPointArray[], char endPointArray[], int weightVisitArray[], int adjacencyArray[]);

    and later when you call the function you have:

    char Prim(char edgeArray1[], char edgeArray2[], int weightArray[], char nodeArray[],
    char startPointArray[], char endPointArray[], int weightVisitArray[], int adjacencyArray[][])

    notice that the adjacencyArray in the prototype is a 1D array and in the function call it is a 2D array

    Hope this helps

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Is everyone using really old lame compilers? Because unless I'm mistaken, EVERY modern compiler will give you a line number telling you where the problem is located to within 3 lines. That kind of narrows it down enough to find an extra [], no?
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. Off by a penny problem
    By ninety3gd in forum C++ Programming
    Replies: 2
    Last Post: 05-18-2009, 05:41 PM
  3. fullscreen toggling problem
    By hannibar in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2005, 07:06 PM
  4. Replies: 4
    Last Post: 08-15-2002, 11:35 AM
  5. Won't Return pointer, i can't find why...
    By ss3x in forum C++ Programming
    Replies: 2
    Last Post: 02-28-2002, 07:50 PM

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