#include <stdio.h>
#include <stdlib.h>
char* format(char* buffer,size_t size,
const char* name,int quantity,int weight){
snprintf(buffer,size,"Item: %s Quantity: %d Weight: %d",name,quantity,weight);
return buffer;
}
int main()
{
char *buffer = (char*)malloc(90);
printf("%s\n",format(buffer,sizeof(buffer),"Axle",25,45));
return 0;
}
When i run the above program, i expect the output
Item: Axle Quantity: 25 Weight: 45
But the output i got is
Item : A
Can someone help me.