Thanks, that was just what i was looking for. However i have now run into an all new problem that I am having trouble dealing with.
Code:
#include <stdio.h>
#include <stdlib.h>
/* Prototypes of local functions */
int get_num_routes(int num_roads, int *road_type);
int main(int argc, char *argv[])
{
int num_roads = argc - 1;
/* To create an integer array from the input char array */
int i;
int road_type[num_roads];
for(i = 0; i < num_roads; i++)
{
road_type[i] = atoi(argv[i+1]);
}
/* -----------------end road type thing-------------------*/
int num_routes = get_num_routes(num_roads, *road_type);
return 0;
}
/* Calculate the number of routes in this particular intersection */
int get_num_routes(int num_roads, int *road_type)
{
int i, j;
int num_into = 0; /* Number of one way roads into the intersection */
int num_outof = 0; /* Number of one way roads out of the intersection */
int num_routes = 0;
for (i = 0; i < num_roads; i++)
{
if(road_type[i] == 0)
num_into++;
else if (road_type[i] == 1)
num_outof++;
}
/* code to calculate num_routes value goes here */
return num_routes;
}
This gives the problem:
Code:
23: warning: passing arg 2 of `get_num_routes' makes pointer from integer without a cast
If anyone has got any ideas about how to deal with this problem then i would be super grateful.
Cheers people,
-Nick