THis is a long peice of code.
I colored the important parts in red.
I get the error: undefined reference to `recursiveFunction'
Please don't try to understand what that code does because I am not sure it will work correctly once it is error free.
Code:#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <errno.h> #include <sys/types.h> void recursiveFunction(int position, int nodesTrav[20],int cost,int complete); int main(int argc, char *argv[]) { //5 int arrayGraph[3][40];//one value for one node the other for the other node that are connected and the third value for the weight. int arrayPath[40][40];// Path taken. The array is shared between the threads. When one is writing is array no other threads must be able to access it. int complete[40];//if path complete it's value will be 0 else it's -1 int N; //number of nodes. int T; char file[30]; int arrayCost[20]; int nodesTraversedd[20]; FILE *input; if(argc > 2) { T = atoi(argv[1]); if((input = fopen( argv[2], "r") ) == NULL) printf("Could Not open file\n"); printf("T: %d and file: %s\n",T,argv[2]); }//end of if(argc > 2) else { while(1) { printf("Please enter the number of threads to be created: "); if(scanf("%d", &T) == 1) { printf("Please enter the name of the file: "); if(scanf("%s", &file) == 1) { if(T>-1) { printf("OMAX\n"); if(( input = fopen( file, "r") ) != NULL) break; }//end of if(T>-1) }//if(scanf("%s", &file) == 1) }//end of if(scanf("%d", &T) == 1) else T = -2; }//end of while(true) }//end else int i = 0; int u = 0; for(i = 0;i< 40;i++) { for(u = 0;u< 40;u++) { arrayPath[i][u] = -1; }//end of for(u = 0;u< 20;u++) arrayGraph[0][i] = -1; arrayGraph[1][i] = -1; arrayGraph[2][i] = -1; complete[i] = -1; }//end of for(i = 0;i< 20;i++) for(i = 0;i< 20;i++) { arrayCost[i] = -1; nodesTraversedd[i] = -1; } int z; int s; int r = 0; char getchar; char str[2]; int modulo; int mod = 0; int count1 = 0; int count2 = 1; int count3 = 0; int countA = 0; for(z = 0; z < 1000; z++){ getchar = getc( input ); if(getchar == '0' ||getchar == '1' ||getchar == '2' ||getchar == '3' ||getchar == '4' ||getchar == '5' ||getchar == '6' || getchar == '7' ||getchar == '8' ||getchar == '9'){ //printf("%c ",getchar); str[0] = getchar; str[1] = '\0'; s = atoi(str); if(r==0) { N=s; mod = s; r++; } else{ //printf("Donkey\n"); arrayGraph[2][countA] = s;//insert the weight in the array. arrayGraph[0][countA] = count1;//insert the row number. arrayGraph[1][countA++] = count2++;//insert the row number. if((count2 % mod ) == 0) { //mod--; count3++; count1 = count3; count2 = count3 +1; //printf("OMAZZZ\n"); } //printf("mod: %d count1: %d\n",mod,count1); }//end of else //printf("%d ",s); }//end of if(getchar == '0' ||getchar == '1' ||getchar == '2' ||getchar == '3'... }// end of for(z = 0; z < 1000; z++){ int t = 0; while(1) { if(arrayGraph[0][t] == -1) break; printf("%d %d %d\n",arrayGraph[0][t],arrayGraph[1][t],arrayGraph[2][t]); t++; } //printf("int: %d string: %s\n",argc,argv[2]); //printf("int: %d",i); // read from the file and store values into arrayGraph[3][20] /* int NodePosition = 0; int NodesTraversed[40]; int cost = 0; */ int completeB = 0; int countCost = 0; int startingNode = 0; int nbofEdges = ((N*N - N)/2); recursiveFunction(0, nodesTraversedd,0,0); void recursiveFunction(int position, int nodesTrav[20],int cost,int complete) { int nodesTraversed[20]; int i; for ( i = 0; i<20; i++) { nodesTraversed[i] = nodesTrav[i]; } int arrayAdj[20][2]; int countAdj = 0; int h; for(h = 0; h < 20;h++) arrayAdj[h][0] = -1; if(complete == N && position ==startingNode) { arrayCost[countCost] = cost; countCost++; }//end of if(complete == N) else // recursion { //-------------------------------------- //Adjacent nodes int q; for(q = 0;q < nbofEdges;q++) { if(arrayGraph[0][q] == position ){ arrayAdj[countAdj][0]=arrayGraph[1][q]; arrayAdj[countAdj][1]=arrayGraph[2][q]; countAdj++; }//end of if(arrayGraph[0][q] == position ){ }//end of for(q = 0;q < nbofEdges;q++) for(q = 0;q < nbofEdges;q++) { if(arrayGraph[1][q] == position ){ arrayAdj[countAdj][0]= arrayGraph[0][q]; arrayAdj[countAdj][1]= arrayGraph[2][q]; countAdj++; }//end of if(arrayGraph[1][q] == position ){ }//end of for(q = 0;q < nbofEdges;q++) //---------------------------------------- //Traversed? q = 0; h = 0; while(arrayAdj[q][0] != -1) { while(nodesTraversed[h] != -1){ if(nodesTraversed[h] == arrayAdj[q][0]) { arrayAdj[q][0] = -2; } //end of if(nodesTraversed[h] == arrayAdj[q]) h++; }//end of while(nodesTraversed[h] != -1) q++; }//end of while(arrayAdj[q] != -1) //--------------------------------------- //recursion while(arrayAdj[q][0] >-1 ) { if(arrayAdj[q][0] == 0 && complete == (N-2)) { //complete++; //cost = cost + arrayAdj[q][1]; //RECURSION recursiveFunction(arrayAdj[q][0], nodesTraversed, cost + arrayAdj[q][1], complete + 1); }//end of if((arrayAdj[q] == 0 && complete == (N-1)) if(arrayAdj[q][0] > 0) { complete++; recursiveFunction(arrayAdj[q][0], nodesTraversed, cost + arrayAdj[q][1], complete + 1); //cost = cost + arrayAdj[q][1]; //RECURSION } //end of if((arrayAdj[q] > 0) }//end of while(arrayAdj[q] >-1 ) }//end of else // recursion }//end of recursion }//end of main



LinkBack URL
About LinkBacks


