S
sillyhat
Hello,
Can someone please help.
I have come across code similar to this which I prepared as an
example:-
/*-------------8<------------------*/
#define ASIZE 10
int main()
{
char *A[] = { "one", "two","three","four","five",
"six","seven","eight","nine","ten" };
int i;
for (i=0; i<ASIZE; i++)
puts(A);
return 0;
}
/*-------------8<------------------*/
and I would like to know how to code this so that ASIZE is calculated
at compile time - by macros perhaps.
Alternatively I could put an empty string in as the last entry and
ignore ASIZE but I wondered if there were other techniques to determine
the number of items in an array with variable length entries like this.
Thanks for any help given.
Hal
Can someone please help.
I have come across code similar to this which I prepared as an
example:-
/*-------------8<------------------*/
#define ASIZE 10
int main()
{
char *A[] = { "one", "two","three","four","five",
"six","seven","eight","nine","ten" };
int i;
for (i=0; i<ASIZE; i++)
puts(A);
return 0;
}
/*-------------8<------------------*/
and I would like to know how to code this so that ASIZE is calculated
at compile time - by macros perhaps.
Alternatively I could put an empty string in as the last entry and
ignore ASIZE but I wondered if there were other techniques to determine
the number of items in an array with variable length entries like this.
Thanks for any help given.
Hal