J
JAKE
I'm pretty new to ansi c and I'm stuck I'm trying to assemble a string
in a called function. I need to send it three different data types and
return the assembled string. I've been getting errors such as...
28 C:\Dev-Cpp\assemble.c conflicting types for 'assemble'
3 C:\Dev-Cpp\assemble.c previous declaration of 'assemble' was here
30 C:\Dev-Cpp\assemble.c syntax error before "a"
here's what I have so far....
#include <stdio.h>
void assemble(float, int, char, char[]);
int main()
{
float a;
int b;
char c, all[6];
printf("ENTER A FLOATING POINT NUMBER:\n");
scanf("%f", &a);
printf("/nENTER A INTERGER:\n");
scanf("%d", &b);
printf("/nENTER A CHARACTER:\n:");
scanf("%c", &c);
assemble(a, b, c, all);
puts(all);
return 0;
}
void assemble (float *a, int *b, char *c, char *all)
{
sprintf(all,"%f, %d, %c" a, b, c);
return;
}
Am I supposed to convert the data types before I pass them to the
function?
Appreciate any help.
in a called function. I need to send it three different data types and
return the assembled string. I've been getting errors such as...
28 C:\Dev-Cpp\assemble.c conflicting types for 'assemble'
3 C:\Dev-Cpp\assemble.c previous declaration of 'assemble' was here
30 C:\Dev-Cpp\assemble.c syntax error before "a"
here's what I have so far....
#include <stdio.h>
void assemble(float, int, char, char[]);
int main()
{
float a;
int b;
char c, all[6];
printf("ENTER A FLOATING POINT NUMBER:\n");
scanf("%f", &a);
printf("/nENTER A INTERGER:\n");
scanf("%d", &b);
printf("/nENTER A CHARACTER:\n:");
scanf("%c", &c);
assemble(a, b, c, all);
puts(all);
return 0;
}
void assemble (float *a, int *b, char *c, char *all)
{
sprintf(all,"%f, %d, %c" a, b, c);
return;
}
Am I supposed to convert the data types before I pass them to the
function?
Appreciate any help.