We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
void PWM_Config(uint8_t TIM_PERIOD, uint8_t TIM_PULSE) { . . . } int main() { PWM_Config(); // THIS LINE SHOWS AN ERROR . . . }
ERROR LIST:
main.c(251): error: #165: too few arguments in function call PWM_Config();
BUT, If I write the program below, there is an no error
void PWM_Config() { . . . } int main() { PWM_Config(); // NO ERROR . . . }
KINDLY HELP!
Is this some kind of joke?
You find it strange if the compiler isn't happy when you tell it "This function takes x parameters - and they are of type 1, type 2, type 3, ... - but I prefer to call it with a completely different list of parameters/types?"
If you write the code for PWM_Config(), then you set the rules for the parameters it should take - and then you need to follow these rules.
If PWM_Config() is written by someone else, then you have to follow the rules that "someone else" did set up when designing the function.
If you buy a car with the steering wheel to the right, you just can't get in on the left side and expect to drive the car - you need to adapt to the situation.
Next thing to realize here is that a function prototype with () in C is a function prototype that doesn't tell what parameters it takes while in C++ it's a function prototype for a function that takes exactly zero parameters. In C, you are expected to write:
int my_function_that_takes_zero_parameters(void);
to explain that there exists a function - and that the function most definitely do not take any parameters.
please understand.I am not cleared with your words.
Initially, I programmed
The above program was been made, because some value is declared within the program.
Now. the values are input from outside of program so I am using COMMAND HANDLER so when I give certain value it should have to store in the TIM_PERIOD and TIM_PULSE .
so I am rewriting the program,like below
Now this shows an error. I want to know the exact reason.
Moreover, I also want to know the write way to call this below function from the int main()
void PWM_Configvoid PWM_Config(uint8_t TIM_PERIOD, uint8_t TIM_PULSE)
Thank you
I normally don't like responding to posts from consultants.
The reason is simple. You're stating that the function PWM_Config takes two parameters. Then you attempt to call it with none.
If you want to call it from main (or anywhere else), you MUST supply two arguments to go with it.
Example:
int main() { PWM_Config(1,2) . . . }
This is basic C!
Thanks. Got it.
Maybe read this? www.shrani.si/.../cfordummies.pdf