simi
asked on
function arguments
Hi
Is there a way I could reffer the arguments of a function the same way as the arguments for the main function ?
ex.
void dummyFunction(char* arg1, char* arg2, char* arg3)
{
int count;
for(count = 0; count < 3; count++)
{
alocate memory for each argument one by one
}
}
Thanks
Is there a way I could reffer the arguments of a function the same way as the arguments for the main function ?
ex.
void dummyFunction(char* arg1, char* arg2, char* arg3)
{
int count;
for(count = 0; count < 3; count++)
{
alocate memory for each argument one by one
}
}
Thanks
ASKER
Thanks
ASKER
I want to grade your answer but the system just provide me with the posibility to write a comment. The grading part has vanished.
How can I grade it ?
How can I grade it ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
void dummyFunction( char *args[3] ){
int count;
for( count = 0; count < 3; count++ ){
char *copy;
copy = malloc(strlen(args[count])
strcpy(copy,args[count]);
printf("%s\n",copy);
free(copy);
}
}
main(){
char *args[3] ={"hello", "world", ""};
dummyFunction(args);
}