In C, when defining an array I can do the following:
int arr[] = {5, 2, 9, 8};
And thus I defined it and filled it up, but how do I define it in my .h file, and then fill it in my .c?
Like do something like
int arr[];
arr = {5, 2, 9, 8};
I’m pretty new to C, not sure how it would look
any suggestions?
Normally, you’d put:
In the .h file, and:
In the .c file.
Edit: Dale Hagglund and KevinDTimm raise good points: you only want to put the initialization in one .c file, and you only need to put anything in the .h file if you’re going to access
arrfrom code in more than one .c file.