Reputation: 7
I keep getting "Unknown type name 'place' even though I wrote the enum correct I can not see the error on what I am doing wrong. thanks
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
void pass(place x);
typedef enum{
house, second
} place;
int main()
{
pass(house);
return 0;
}
void pass(place x){
if(x == house){
printf("We are in a house \n")
}else if(x == second){
printf("We live in the second house \n");
}
return;
}
Upvotes: 1
Views: 1362
Reputation: 2237
Your enum place
declaration is fine. The problem is you're defining a function with place before the existence of place
is known. Change the order and define your place enum first, before you pass()
function.
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
typedef enum{
house,
second
} place;
void pass(place x); // This function forward declaration must be after you defined place.
int main()
{ /* .. */ }
Upvotes: 3