Why pass structs? (not struct pointers)
Dave Decot
decot at hpisod2.HP.COM
Wed Mar 4 08:49:27 AEST 1987
The example I provided to demonstrate a syntax for array lvalues incorrectly
included several declarations for items which should have been "char" instead
of "int". Here's the example again, corrected.
Dave Decot
hpda!decot
#define ARRSIZ 20
main ()
{
char (reverse())[ARRSIZ]; /* function returning array [ARRSIZ] of char */
char arr[ARRSIZ] = "this is amazing";
arr[] = reverse(arr[]);
printf("%s\n", arr);
}
char (reverse(s))[ARRSIZ]
char s[ARRSIZ];
{
char tmp[ARRSIZ], *tp = tmp;
int i;
for (i = strlen(s)-1; i >= 0; i--)
*tp++ = s[i];
*tp = '\0';
return tmp[];
}
More information about the Comp.lang.c
mailing list