Hi,
I am trying to run this program, but I am getting two error messages that prevent it from running. I don't really understand what the problem is or how to fix it. Could someone please help? Here are the errors:
"error C2664: 'sprintf' : cannot convert parameter 2 from 'int' to 'const char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast"
"error C2562: 'assemble' : 'void' function returning a value: see declaration of 'assemble'"
And here is the code:
#include <stdio.h>
#include <string.h>
#include "string.h"
int main()
{
void assemble(char*input, int num, char let, float flo);
char input[100];
int num;
char let;
float flo;
printf("\nPlease enter an integer:\n");
scanf("%d", &num);
printf("\nPlease enter a character:\n");
scanf("%c", &let);
printf("\nPlease enter a floating point number:\n");
scanf("%f", &flo);
assemble(input, num, let, flo);
puts(input);
return 0;
}
void assemble(char*input, int num, char let, float flo)
{
input = sprintf(input, "%d, %c, %f", num, let, flo);
return (input);
}