how about this (this code works)
Code:
// weight_6.c
// structure to function
// weight_4.c & weight_5.c
// written by Jamie Morrissey 6/12/18
#include <stdio.h>
#include <stdlib.h>
struct data {
int day;
int month;
int year;
float pounds;
} weight;
FILE * fptr;
void fprintf_stuff(struct data print_it);
main()
{
printf("Enter date: (MM/DD/YY): ");
scanf("%d/%d/%d", &weight.month, &weight.day, &weight.year);
printf("Enter your weight in pounds: ");
scanf("%f", &weight.pounds);
// call the fprint_stuff() function
fprintf_stuff(weight);
return 0;
}
void fprintf_stuff(struct data print_it)
{
fptr = fopen("new_weight_new.txt", "a+");
if( fptr == 0)
{
printf("Error! File not found!\n");
exit(1);
}
fprintf(fptr, "Here is your weight: ");
fprintf(fptr, "%d/%d/%d - %.1f\n", weight.month, weight.day, weight.year, weight.pounds);
fclose(fptr);
}