# help with code.....

This is a discussion on help with code..... within the C Programming forums, part of the General Programming Boards category; ok... here is my code.... Code: #include <stdio.h> #include <stdlib.h> #define NAMESIZE 40 #define NOPATH -1.0 #define AHMAD 0 #define ...

1. ## help with code..... (graph with linked list implementation)

ok... here is my code....
Code:
```#include <stdio.h>
#include <stdlib.h>
#define NAMESIZE 40
#define NOPATH -1.0

#define GURWIND 1
#define AHFATT 2
#define BOB 3
#define NUMPLACE 4

struct placeNode{
char name[NAMESIZE];
};

float distance;
struct placeNode *place;
};

struct placeNode places[NUMPLACE] = {
{"Gurwinder Singh's Clinic", NULL},
{"Ah Fatt's Auto Repair", NULL},
{"Bob's Restaurant", NULL}
};

float distance, struct placeNode *to);

struct placeNode *to);

int main(void){
int fromIndex, toIndex;
struct placeNode *from, *to;
float distance;
printf("From:"); scanf("%d",&fromIndex);
printf("To:"); scanf("%d",&toIndex);

from = &places[fromIndex];

to = &places[toIndex];
printf("From %s to %s ", from->name,to->name);

if(distance!=NOPATH)printf("it is %2.1f km\n",distance);
return(0);
}

}

float distance,struct placeNode *to){
}

struct placeNode *to){
current=current->next){
if (current->place == to)
return current->distance;
}
return(NOPATH);
}```
since there is no path from ahmad's mini market to bob's restaurant.... how am i able to calculate the distance from ahmad's mini market to bob's restaurant??

as a default, i have state that since there is no direct path from those places, i would just print "no direct path"

but how am i to alter this code to enable me to calculate the distance to another place with no direct link? (lets say from ahmad's mini market, passing by ahfatt's auto repair and to bob's restaurant?

`road = (struct roadNode *) malloc(sizeof (struct roadNode));`