PDA

View Full Version : whats wrong with this code??


mile1982
09-09-2004, 06:51 AM
hey

when i try and compile i keep getting this error that 'error C2115: 'function' : incompatible types' on the following line of the code:

for (i = 0; i < nCommands; ++i) {

printf(" Command[%d]: \n", i);
printComStruct(com[i]); // HERE

}

the following is my printComStruct function:

void printComStruct(struct command *com) { /* print function */

int i;

fprintf(stderr,"com_pathname=%s\n", com->com_pathname);
fprintf(stderr,"argc=%d\n", com->argc);

for(i=0; com->argv[i]!=NULL; i++)

fprintf(stderr,"argv[%d]=%s\n", i, com->argv[i]);

fprintf(stderr,"#######\n");

if (com->redirect_in == NULL)
fprintf(stderr,"redirect_in=NULL\n");

else
fprintf(stderr,"redirect_in=%s\n", com->redirect_in);

if (com->redirect_out == NULL)
fprintf(stderr,"redirect_out=NULL\n");

else
fprintf(stderr,"redirect_out=%s\n", com->redirect_out);

fprintf(stderr,"com_suffix=%c\n\n", com->com_suffix);

} /*end of function*/


can anyone please help. cheers

mile

Nope
09-09-2004, 08:48 AM
That's simple...


Definition:
void printComStruct(struct command *com)

Your call
printComStruct(com[i]);

actually is
printComStruct(struct command com)


So you just have to do it like this:
printComStruct( &com[i] );

Cheers.

mile1982
09-09-2004, 09:48 AM
thanks mate
appreciate it

mile1982

i3839
09-09-2004, 04:54 PM
Please use the ... tags next time, it makes code much more readable because it preserves the formatting.