From owner-freebsd-hackers Tue Nov 21 09:42:56 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id JAA09046 for hackers-outgoing; Tue, 21 Nov 1995 09:42:56 -0800 Received: from rocky.sri.MT.net (rocky.sri.MT.net [204.182.243.10]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id JAA09041 for ; Tue, 21 Nov 1995 09:42:51 -0800 Received: (from nate@localhost) by rocky.sri.MT.net (8.6.12/8.6.12) id KAA25161; Tue, 21 Nov 1995 10:45:03 -0700 Date: Tue, 21 Nov 1995 10:45:03 -0700 From: Nate Williams Message-Id: <199511211745.KAA25161@rocky.sri.MT.net> To: Jerry.Kendall@vmicls.com (Jerry Kendall) Cc: freebsd-hackers@freebsd.org Subject: Re: HELP with typedef In-Reply-To: <9511211559.AA27128.gonzo@vmicls.com> References: <9511211559.AA27128.gonzo@vmicls.com> Sender: owner-hackers@freebsd.org Precedence: bulk > I need to create a subroutine that is passed a pointer to > an array of pointers to strings. ie: address of (char *list[]). The program you supplied was close, but not quite. I cleaned it up just a little bit and it follows. ---------------------------------------------------- #include typedef char *StringList[]; StringList List = {"one","two","three","four","END OF LIST",""}; void PrintList( StringList List) { int x; for(x = 0; List[x][0] != 0; x++) printf("List entry %d: %s\n", x, List[x]); } int main() { PrintList(List); return ( 1 ); } ---------------------------------------------------- It now compiles with 'gcc -Wall', and works like I think you intend it to do. Note how I changed the end of the for loop condition. You are using an empty string, so we need to look at the first character in the string to determine if it's '\0'. If you want to do it slightly different (and somewhat more standard), you could do it this way. StringList List = {"one","two","three","four","END OF LIST",NULL}; ... for(x = 0; List[x] != NULL; x++) ... Note the NULL as the last entry vs "". This would allow you to use empty strings. Nate