Greetings,
I am a bit new at programming and am working on a project for my own amusement. The problem is I have created a structure and I want to make an array of the structure, but do it in a fuction in such a way that I can create the elements at declaration then be able to use that information in main.
So I decided to try to use a pointer to the struct and return that to a declared pointer in main - I wasn't sure how else to do this.
Anyway - here's what I have. Any help would be appreciated!
Trying to compile this I get 2 'incompatible type' errors.Code:#include <stdio.h> typedef struct nountypes { char n[15]; }nouns; nouns* defNouns(); int main(void) { nouns *nWords; *nWords = defNouns(); } nouns* defNouns() { nouns *nWordsptr; nouns nWords[] = {"sun", "ship", "darknes"}; *nWordsptr = nWords[0]; return *nWordsptr; }



LinkBack URL
About LinkBacks



)