Path: utzoo!utgpu!water!watmath!watdragon!violet!ajmyrvold From: ajmyrvold@violet.waterloo.edu (Alan Myrvold) Newsgroups: comp.lang.c Subject: Re: Help me cast this! Keywords: pointer to array of struct Message-ID: <6621@watdragon.waterloo.edu> Date: 3 May 88 11:15:43 GMT References: <294@fedeva.UUCP> Sender: daemon@watdragon.waterloo.edu Reply-To: ajmyrvold@violet.waterloo.edu (Alan Myrvold) Distribution: na Organization: U. of Waterloo, Ontario Lines: 31 In article <294@fedeva.UUCP> wrd3156@fedeva.UUCP (Bill Daniels) writes: > >How do I cast the malloc() in line 12 of the following program to avoid >the lint cries of "warning: illegal pointer combination" et al? ... > struct outfile { > int j; > int k; > } (*output)[]; > > output = malloc(sizeof(struct outfile) * 3); Did you try : output = (struct outfile **) malloc(sizeof(struct outfile) * 3); This goes through lint here, althougth lint complains that sizeof(struct outfile) * 3 is long, and should be unsigned. So output = (struct outfile **) malloc((unsigned) sizeof(struct outfile) * 3); should clear everything up. ------------------------------------------------------------------- Si je t'aime? Bien sur que je t'aime! Ne suis-je pas en train de te le prouver encore une fois, dans ce lit? ------------------------------------------------------------------- Alan Myrvold ajmyrvold@violet.waterloo.edu -------------------------------------------------------------------