我有一个简单的程序,它读取一行,包含 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");
}