Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
返回的进程-1073741819(0xC0000005)_C_Windows - Fatal编程技术网

返回的进程-1073741819(0xC0000005)

返回的进程-1073741819(0xC0000005),c,windows,C,Windows,我正试图为我的C编程课写一个程序。标题中的错误在我以零错误和警告运行程序后不断弹出。这是我的密码 /* Write a program that contains the function calories() that is to accept a long integer number total and the addresses of the integer variables pizza, chips, apples, and mustard. The passed lon

我正试图为我的C编程课写一个程序。标题中的错误在我以零错误和警告运行程序后不断弹出。这是我的密码

/*
   Write a program that contains the function calories() that is to accept a long integer number total and the addresses of the integer variables pizza, chips, apples, and mustard.
   The passed long integer represents the total number of calories you are able to consume in this meal, and the function is to determine the 
   number of calories in slices of pizza, bags of chips, apples,
   and teaspoons of mustard in the passed value, writing these values directly into the respective variables declared in the calling function.

   This function will be called from the main program and when it returns to main, it will print out the values of variables pizza, chips, apples, and mustard.

   The calories in our favorite foods are in this order:
   pizza--385 calories each slice
   chips--170 calories each bag
   apple--80 calories each
   mustard--5 calories each tsp.
   For example, if I enter a total amount of calories of 1050, I can eat:
   2 slices pizza @ 770 calories (1050 - 770 = 280 calories remain)
   1 bag of chips @ 170 calories (280 - 170 = 110 calories remain)
   1 apple @ 80 calories (110 - 80 = 30 calories remain)
   6 tsp. mustard @ 30 calories
   */
#include <stdio.h>
int main()
{
    int calorie(int, int , int, int);

    int total, pizza, chips, apples, mustard, sum, sum1, sum2, sum3;

    pizza = 385;
    chips = 170;
    apples = 80;
    mustard = 5;

    printf("How many calories do you want to consume during your meal?");
    scanf("%d", total);

    total=calorie(pizza, chips, apples, mustard);


    printf("Pizza: %.2d", &pizza);
    printf("Chips: %.2d", &sum1);
    printf("Apples: %.2d", &sum2);
    printf("Mustard: %.2d", &sum3);

    return 0;

}

int calorie(pizza, chips, apples, mustard)
{
    int clfp, sum1, sum2, clfa, clfc, sum3, calorie;

    pizza = calorie/pizza;
    sum1 = calorie-pizza; /*calories left from pizza*/

    sum1 = clfp/chips;
    clfc = clfp-chips; /*calories left from chips*/

    sum2 = clfc/apples; /*calories life from apples*/
    clfa = clfc-apples ;

    sum3 = clfa/mustard;

    return pizza, sum1, sum2, sum3;
}
/*
编写一个包含函数carries()的程序,该函数用于接受一个长整数和整数变量pizza、chips、apples和sarment的地址。
传递的长整数表示您在这顿饭中能够消耗的卡路里总数,函数用于确定
比萨饼片、薯条袋、苹果、,
在传递的值中添加一茶匙芥末,将这些值直接写入调用函数中声明的相应变量中。
这个函数将从主程序调用,当它返回到主程序时,它将打印出变量pizza、chips、apples和芥末的值。
我们最喜欢的食物中的卡路里按以下顺序排列:
比萨饼——每片385卡路里
薯片——每袋170卡路里
苹果--每个80卡路里
芥末——每茶匙5卡路里。
例如,如果我输入的卡路里总量为1050,我可以吃:
770卡路里的2片比萨(1050-770=剩余280卡路里)
1袋薯片,热量为170卡路里(280-170=剩余110卡路里)
1个苹果,热量为80卡路里(110-80=剩余30卡路里)
6茶匙。芥末@30卡路里
*/
#包括
int main()
{
int卡路里(int,int,int,int);
整数总计、比萨饼、薯条、苹果、芥末、sum、sum1、sum2、sum3;
比萨饼=385;
芯片=170;
苹果=80;
芥末=5;
printf(“您希望在用餐期间消耗多少卡路里?”);
scanf(“%d”,总计);
总热量=卡路里(比萨饼、薯条、苹果、芥末);
printf(“比萨饼:%.2d”和比萨饼);
printf(“芯片:%.2d”和sum1);
printf(“苹果:%.2d”和sum2);
printf(“芥末:%.2d”和sum3);
返回0;
}
热量(比萨饼、薯条、苹果、芥末)
{
int clfp、sum1、sum2、clfa、clfc、sum3、卡路里;
比萨饼=卡路里/比萨饼;
sum1=热量比萨;/*比萨剩余的热量*/
sum1=clfp/芯片;
clfc=clfp薯片;/*薯片剩余热量*/
sum2=clfc/苹果;/*来自苹果的卡路里寿命*/
clfa=clfc苹果;
sum3=氯代脂肪酸/芥末;
返回比萨饼,sum1,sum2,sum3;
}
scanf(“%d”,总计)应为
scanf(“%d”,总计(&T)

另外,在
scanf()
调用中读入
total
的值并完全忽略它并通过调用覆盖该值也没有多大意义:

total=calorie(pizza, chips, apples, mustard);
另一个问题是使用变量
carorie
,但从未在
carorie()
函数中对其进行初始化:

pizza = calorie/pizza;
//       ^^^^^ uninitialized
我还感到惊讶的是,您的
carolie()
函数定义甚至可以编译,因为paren中的标识符都不是类型。但是我发现它是为我编译的,所以我知道什么(我猜它是隐式的
int
抬起它丑陋的头)

int卡路里(比萨饼、薯条、苹果、芥末)/
scanf(“%d”,总计)应为
scanf(“%d”,总计(&T)

另外,在
scanf()
调用中读入
total
的值并完全忽略它并通过调用覆盖该值也没有多大意义:

total=calorie(pizza, chips, apples, mustard);
另一个问题是使用变量
carorie
,但从未在
carorie()
函数中对其进行初始化:

pizza = calorie/pizza;
//       ^^^^^ uninitialized
我还感到惊讶的是,您的
carolie()
函数定义甚至可以编译,因为paren中的标识符都不是类型。但是我发现它是为我编译的,所以我知道什么(我猜它是隐式的
int
抬起它丑陋的头)

int卡路里(比萨饼、薯条、苹果、芥末)/1)变化

2) 换电话

calorie(pizza, chips, apples, mustard);

3) 换回

return pizza, sum1, sum2, sum3;

4) 改变

5) 改变

1) 改变

2) 换电话

calorie(pizza, chips, apples, mustard);

3) 换回

return pizza, sum1, sum2, sum3;

4) 改变

5) 改变


在所有这些建议之后,下面是代码的固定版本,供您参考:

/*
   Write a program that contains the function calories() that is to accept
   a long integer number total and the addresses of the integer variables 
   pizza, chips, apples, and mustard.

   The passed long integer represents the total number of calories you are 
   able to consume in this meal, and the function is to determine the number 
   of calories in slices of pizza, bags of chips, apples, and teaspoons of 
   mustard in the passed value, writing these values directly into the 
   respective variables declared in the calling function.

   This function will be called from the main program and when it returns to 
   main, it will print out the values of variables pizza, chips, apples, and 
   mustard.

   The calories in our favorite foods are in this order:
   pizza--385 calories each slice
   chips--170 calories each bag
   apple--80 calories each
   mustard--5 calories each tsp.
   For example, if I enter a total amount of calories of 1050, I can eat:
   2 slices pizza @ 770 calories (1050 - 770 = 280 calories remain)
   1 bag of chips @ 170 calories (280 - 170 = 110 calories remain)
   1 apple @ 80 calories (110 - 80 = 30 calories remain)
   6 tsp. mustard @ 30 calories
   */

#include <stdio.h>

void calorie(long, int *, int *, int *, int *);

int main()
{
    long total;
    int pizza, chips, apples, mustard;

    printf("How many calories do you want to consume during your meal? ");
    scanf("%ld", &total);

    calorie(total, &pizza, &chips, &apples, &mustard);

    printf("Pizza:   %2d\n", pizza);
    printf("Chips:   %2d\n", chips);
    printf("Apples:  %2d\n", apples);
    printf("Mustard: %2d\n", mustard);

    return 0;

}

void calorie(long total, int *pizza, int *chips, int *apples, int *mustard)
{
    const int per_pizza = 385;
    const int per_chips = 170;
    const int per_apples = 80;
    const int per_mustard = 5;

    *pizza = total / per_pizza;
    total -= *pizza * per_pizza;

    *chips = total / per_chips;
    total -= *chips * per_chips;

    *apples = total / per_apples;
    total -= *apples * per_apples;

    *mustard = total / per_mustard;
    total -= *mustard * per_mustard;
}
/*
编写一个包含要接受的函数carries()的程序
一个长整数和整数变量的地址
比萨饼、薯条、苹果和芥末。
传递的长整数表示您摄入的卡路里总数
能够在这顿饭中消费,其功能是确定数量
比萨饼片、薯条袋、苹果和茶匙巧克力中的卡路里含量
输入传递的值,将这些值直接写入
调用函数中声明的各个变量。
此函数将从主程序调用,并在返回时调用
main,它将打印出变量pizza、chips、apples和
芥末
我们最喜欢的食物中的卡路里按以下顺序排列:
比萨饼——每片385卡路里
薯片——每袋170卡路里
苹果--每个80卡路里
芥末——每茶匙5卡路里。
例如,如果我输入的卡路里总量为1050,我可以吃:
770卡路里的2片比萨(1050-770=剩余280卡路里)
1袋薯片,热量为170卡路里(280-170=剩余110卡路里)
1个苹果,热量为80卡路里(110-80=剩余30卡路里)
6茶匙。芥末@30卡路里
*/
#包括
无效卡路里(长,整数*,整数*,整数*,整数*);
int main()
{
长期总计;
int比萨饼、薯条、苹果、芥末;
printf(“您希望在用餐期间消耗多少卡路里?”);
scanf(“%ld”&总计);
卡路里(总量、比萨饼、薯条、苹果和芥末);
printf(“比萨饼:%2d\n”,比萨饼);
printf(“芯片:%2d\n”,芯片);
printf(“苹果:%2d\n”,苹果);
printf(“芥末:%2d\n”,芥末);
返回0;
}
无效卡路里(总热量、整块比萨饼、整块薯条、整块苹果、整块芥末)
{
每平方英寸常数=385;
每个芯片的常数int=170;
每个苹果的常数=80;
printf("Pizza: %.2d", &pizza);
printf("Chips: %.2d", &sum1);
printf("Apples: %.2d", &sum2);
printf("Mustard: %.2d", &sum3);
printf("Pizza: %.2d", pizza);
printf("Chips: %.2d", sum1);
printf("Apples: %.2d", sum2);
printf("Mustard: %.2d", sum3);
scanf("%d", total);
scanf("%d", &total);
/*
   Write a program that contains the function calories() that is to accept
   a long integer number total and the addresses of the integer variables 
   pizza, chips, apples, and mustard.

   The passed long integer represents the total number of calories you are 
   able to consume in this meal, and the function is to determine the number 
   of calories in slices of pizza, bags of chips, apples, and teaspoons of 
   mustard in the passed value, writing these values directly into the 
   respective variables declared in the calling function.

   This function will be called from the main program and when it returns to 
   main, it will print out the values of variables pizza, chips, apples, and 
   mustard.

   The calories in our favorite foods are in this order:
   pizza--385 calories each slice
   chips--170 calories each bag
   apple--80 calories each
   mustard--5 calories each tsp.
   For example, if I enter a total amount of calories of 1050, I can eat:
   2 slices pizza @ 770 calories (1050 - 770 = 280 calories remain)
   1 bag of chips @ 170 calories (280 - 170 = 110 calories remain)
   1 apple @ 80 calories (110 - 80 = 30 calories remain)
   6 tsp. mustard @ 30 calories
   */

#include <stdio.h>

void calorie(long, int *, int *, int *, int *);

int main()
{
    long total;
    int pizza, chips, apples, mustard;

    printf("How many calories do you want to consume during your meal? ");
    scanf("%ld", &total);

    calorie(total, &pizza, &chips, &apples, &mustard);

    printf("Pizza:   %2d\n", pizza);
    printf("Chips:   %2d\n", chips);
    printf("Apples:  %2d\n", apples);
    printf("Mustard: %2d\n", mustard);

    return 0;

}

void calorie(long total, int *pizza, int *chips, int *apples, int *mustard)
{
    const int per_pizza = 385;
    const int per_chips = 170;
    const int per_apples = 80;
    const int per_mustard = 5;

    *pizza = total / per_pizza;
    total -= *pizza * per_pizza;

    *chips = total / per_chips;
    total -= *chips * per_chips;

    *apples = total / per_apples;
    total -= *apples * per_apples;

    *mustard = total / per_mustard;
    total -= *mustard * per_mustard;
}