So I’m a little confused here. I’m working on a bigger project, but ran into a few problems, so I wrote a little test case using a simple struct:
#include <stdio.h>
typedef struct{
int property1;
}test;
int main(){
test testing = getNumber();
printf("%d",testing.property1);
return 0;
}
test getNumber(){
test testing = {2};
return testing;
}
All I’m trying to do is read a property from the test struct returned from getNumber(). However, the compiler complains with the following error:
test.c(8) : error C2440: ‘initializing’ : cannot convert from ‘int’ to ‘test’
So my question is: why is this function trying to return an int despite me specifying a test return type? How do I fix this? Am I just blind to something simple?
You’re missing a prototype: