0

I want to process command line parameters in seperate function but couldnt pass them. What is the right declaration and definition? And any resource about passing parameters, writing function definition/declaration?

I will use getopt() function in cmd_line() function.

...
...
void cmd_line(*int, *char[]);

int main(int argc, char *argv[]){
    cmd_line(&argc, argv);
    return 0;
}

void cmd_line(int *argc, char *argv[]){
...
...
}
3
  • 1
    *int looks ok to you? Commented Feb 13, 2022 at 11:47
  • but im taking address of argc argument. And what about pointer array?im getting lots of warn like "implicit declaration" Commented Feb 13, 2022 at 11:49
  • if i change *int still getting errors Commented Feb 13, 2022 at 11:52

1 Answer 1

1

Tried to find a duplicate, but did not find any in this context. To make it searchable, here is the relevant error:

main.c:1:15: error: expected declaration specifiers or ‘...’ before ‘*’ token
    1 | void cmd_line(*int, *char[]);
      |               ^
main.c:1:21: error: expected declaration specifiers or ‘...’ before ‘*’ token
    1 | void cmd_line(*int, *char[]);
      | 

The problem is that

void cmd_line(*int, *char[]);

should be

void cmd_line(int*, char*[]);
Sign up to request clarification or add additional context in comments.

1 Comment

yeah thanks. when i changed place of *, it worked. but now i have further problems:)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.