I am trying to make a global array of structs, however the way in which I thought I would go about this doesn't work. For the application I need requires it be be global however will not know the size until inside the main() function. My code is as follows:
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
//
struct player {
char letter;
};
struct player *players;
int main(int argc, char** argv){
check _variables();
int *inpBuff;
inpBuff = convert_input(argv[1], argv[2]);
int numPlayers = inpBuff[0];
players = malloc(numPlayers*sizeof(player));
return 1;
}
I receive the error: error: 'player' undeclared (first use in this function) players = malloc(numPlayers*sizeof(player));
struct player.char** argvworks for? why two**after char?1is not a portable exit status. On at least one system it means "success", but on Unix/Windows it is an error code. The portable return values ofmainare0orEXIT_SUCCESSfor success andEXIT_FAILUREfor failure.