#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int main()
{
char name[5][30] = {"Contactless Thermometer","Hand Sanitizers",
"Face Mask", "Surgical Mask",
"Oxygen Mask"};
char code[5][3] = {"CT","HS","FM","SM","OM"};
char donator[5][15] = {"Japan","USA","China","China","Saudi Arabia"};
int noOfShip[5] = {1,1,2,2,2};
float qty[5] = {1.2,3.5,120,38,9};
FILE *fptr;
fptr = fopen("donations.txt","w");
if(fptr == NULL)
{
printf("Error!");
exit(1);
}
fprintf(fptr,"Name of Supply \t\t");
fprintf(fptr,"Supply Code \t");
fprintf(fptr,"Donator \t");
fprintf(fptr,"No. of Shipment \t");
fprintf(fptr,"Quantity Received (millions) \n");
for(int i=0;i<5;i++)
{
fprintf(fptr,"%s \t",name[i]);
fprintf(fptr,"%s \t",code[i]);
fprintf(fptr,"%s \t",donator[i]);
fprintf(fptr,"%d \t",noOfShip[i]);
fprintf(fptr,"%.1f \n",qty[i]);
}
fclose(fptr);
printf("file has been created successfully");
return 0;
}
This is my output:
Name of Supply Supply Code Donator No. of Shipment Quantity Received (millions)
Contactless Thermometer CT Japan 1 1.2
Hand Sanitizers HS USA 1 3.5
Face Mask FM China 2 120.0
Surgical Mask SM China 2 38.0
Oxygen Mask OM Saudi Arabia 2 9.0
Need help to get my informations aligned under its category .