Command with parameters


How to fix my program using C not C++



#include <stdio.h>
#include <string.h>
void func_command(char *input, char *command,int*num_params, float *params);
void main(void)
{
char str[20];
printf("Enter a command :");
gets(str);
char inp [1000];
printf ("Enter an integer :");
int my_int = atof (gets (inp));
printf ("Enter a floating-point number :");
float my_float = atof (gets (inp));
func_command(str,my_int, my_float);
}
void func_command(char *input, char *command,int *num_params, float *params)
{
printf("%s",*command);
printf("%d",*num_params);
printf("%f",*params);
}
Fix what? What's the problem? Compile errors? Doesn't run? Gives the wrong answer? Getting error messages? What messages?
What kind of help are you looking for?

Please learn to use code tags (the <> formatting button) when posting code.

A couple of obvious errors:
1) func_command is declared with 4 parameters, but when you call it, you only call it with 3 parameters. That should be causing a compile error.
2) You need to #include <stdlib.h> if you're going to use atof.



Thank you. I am trying to output the command, the number of parameters, and the parameters
Topic archived. No new replies allowed.