Knowing how to define functions at the right time
c, function, parameters
Solution
The variables you pass to a function are its inputs or (sometimes) its outputs. For example, if you wanted to write a function that adds two integers and returns their sum, you could define
int sum(int m, int n) {
return m + n;
}
The `main()` function is a special case, because it operates on the command-line arguments that are supplied to the program. In most languages, `main()` takes an array of strings, with one word from the command line in each string. In C, it also takes an integer that represents the number of words that were entered on the command line.
Problem
This is a "weird" question, as it confuses me. I have been learning C, and I realized I had a question not in my C book. When starting a function, like `int main()` or `void name()`, HOW do I know what to put in the brackets... like `int main(int argc, char *argv[])` or just `int main()`. It is a stupid question, but I wouldn't know WHEN to use what when programming. Resources to online links would be helpful. Thanks, and sorry for stupidness.