3つの数字で1行を読み取る簡単なプログラムがあります。「製品」のコードである最初の番号をスキップする必要があります。
したがって、2 番目と 3 番目の文字だけを読み取る必要があります。
これどうやってするの?
今までのコード:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int calculate_price (number, value)
{
int price=0;
price= number*value;
return price;
}
int main(void)
{
int number, value, u,price;
FILE *bill, *total_price;
bill= fopen("bill.txt","rt");
total_price= fopen("total_price.txt","wt");
if (bill== NULL)
{
printf("The file cannot be open.\nQuitting the program.\n");
exit(1);
}
if (total_price== NULL)
{
printf("The file canno be written.\nQuitting the program.\n");
exit(1);
}
while (fscanf(bill, "%d %d",&number, &value) != EOF)
{
u=calculate_price(number, value);
fprintf(total_price,"The total price is %d\n", u);
}
printf("File created sucessfully. Check the file.\n");
}