Reputation: 100
I have a code, that is split into multiple files, and which has to use a lot of constant strings(hundreds), and many of them have to be accessed from functions located in several files, what is the most convenient way to do this?
Upvotes: 0
Views: 107
Reputation: 16724
You can make a header called e.g., global.h
and put your constants on it and include where the constants is needed(in fact,you will include for context,because you need to use include guards
for avoid redefinition error)
Upvotes: 3
Reputation: 316
You can use array of pointers where each pointer points to one string. You can pass the string array where ever you want to other functions, but only thing is make it as const so that no one will change that.
Upvotes: 0