I have 2 structs, path and paths. Then, define an array of paths to hold my data:
enum MAX_NEIGHBOR {MAX_NEIGHBOR = 256}; enum MAX_NUM_PATHS {MAX_NUM_PATHS = 100}; typedef struct { int id; int path[MAX_NEIGHBOR]; } path; typedef struct { int id; path pathsIKnow[MAX_NUM_PATHS]; } paths; paths pathsIKnow[MAX_NEIGHBOR]; I am currently initializing the array in a big loop at runtime, which takes too much time. Is there a way I can initialize this without a loop, such as during definition of the paths array?
Current loop code:
void initKnownPaths() { for(int j=0;j<MAX_NEIGHBOR;j++){ paths pathsToI = pathsIKnow[j]; pathsToI.id = 999; for(int i=0 ;i < MAX_NUM_PATHS;i ++){ path pathToupdate = pathsToI.pathsIKnow[i]; pathToupdate.id = 999; for(int j=0 ;j < MAX_NEIGHBOR;j++){ int cPathValue = pathToupdate.path[j]; cPathValue = 999; pathToupdate.path[j] = cPathValue; } pathsToI.pathsIKnow[i] = pathToupdate; pathsIKnow[j] = pathsToI; } } } Thanks!
jis just asking for trouble.