# Thread: Must Be Missing Something Simple!

1. ## Must Be Missing Something Simple!

First, this is NOT for a class. It is NOT homework. I used to write some C code and am trying to remember how to do it - and have written this simple example. I have other examples that work just fine but this one tells me that the function (line 72 and 73) is trying to define a function. I declare the function on line 29 and call it on line 56. I have looked and looked at this - what am I doing wrong???

I get miles per hour from the keyboard.

Please be gentle, I think I just have "brain lock".

Code:
```//
//  main.c
//  boys_program
//
//  Created by Charles Phillips on 6/8/18.
//

#include <stdio.h>
// declare variables
int miles_cl_sealy = 60;  // this is set for now
int miles_sealy_luling = 45;  // set for now
int miles_luling_LaCantera = 70;  // set for now

// mph from stop to stop, variables
int mph_cl_sealy = 30;   // we will enter this
int mph_sealy_luling = 40;  // enter this
int mph_luling_LaCantera = 50;  // enter this

// time from stop to stop, variables
int time_cl_sealy = 1;  // set initial value (hours) then calculate it
int time_sealy_luling = 2;  // set initial value
int time_luling_LaCantera = 3;  // set initial value
int time_cl_LaCantera = 40;  // set initial value, addition of times for "legs" gives final

int time_cl_austin = 2;  // set initial value hours, will be calculated

// functions
int find_time_cl_LaCantera(int mph_cl_sealy, int mph_sealy_luling, int mph_luling_LaCantera); // declare function

int main(void)

{
printf("So You Want To Go Relax For A Week???\n");

char answer = 'x';  // define answer and give it a default value
// miles from stop to stop, not a variable

printf("\nWhat do you want to do? Enter the letter for your response.\n\n");
printf(" a) Austin\n");
printf(" b) La Cantera\n");
printf(" q) Quit\n\n");

case 'a':
printf("Do you want to spend a week in Austin??\n");

printf("Your driving time is: %d minutes\n", time_cl_austin);
break;
case 'b':
printf("Do you want to spend a week in LaCantera??\n");

time_cl_LaCantera = find_time_cl_LaCantera (<#int mph_cl_sealy#>, <#int mph_sealy_luling#>, <#int mph_luling_LaCantera#>);  // call function
printf("Now We Have To Find The Best Route\n");

break;
case 'q':
printf("You said to quit so I will quit\n");
break;
default:
printf("Invalid selection. Try again.\n");
break;
}

return 0;
}

int find_time_cl_LaCantera(int mph_cl_sealy, int mph_sealy_luling, int mph_luling_LaCantera)
{
printf("Do you want to spend a week at La Cantera??\n");
printf("Debug - initial time Clear Lake to La Cantera %d \n", time_cl_LaCantera);
printf("What speed is allowed from Clear Lake to Sealy?\n");
printf("debug - time Clear Lake to Sealy before calculation %d\n", time_cl_sealy); // debug
scanf(" %d", &mph_cl_sealy);  // from keyboard
time_cl_sealy = miles_cl_sealy / mph_cl_sealy;  // hours to sealy    }

printf("What speed is allowed from Sealy to Luling?\n");
printf("debug - time Sealy to Luling before calculation %d\n", time_sealy_luling); // debug
scanf(" %d", &mph_sealy_luling);  // from keyboard
time_sealy_luling = miles_sealy_luling / mph_sealy_luling;

printf("What speed is allowed from Luling to La Cantera?\n");
printf("debug - time Clear Lake to Sealy before calculation %d\n", time_luling_LaCantera); // debug
scanf(" %d", &mph_luling_LaCantera);  // from keyboard
time_luling_LaCantera = miles_luling_LaCantera / mph_luling_LaCantera;
time_cl_LaCantera = time_cl_sealy + time_sealy_luling + time_luling_LaCantera;

printf("time from Clear Lake to Sealy, after calculation %d hours\n", time_cl_LaCantera);
return time_cl_LaCantera;   // this is what the function generates

}
}```

2. This is odd - the system here numbers the lines differently than the one I have???? It inserts blank lines.

3. Well it looks like the brace on line 48 isn't matched properly.

Or the brace on the last line is badly out of position.

4. Oh - the brace on 111 was extra. And I noticed that I had screwed up line 68 but had already fixed it. Too much caffeine or not enough! It is working now, the error I got did not indicate the actual problem. Thanks!!