小编use*_*390的帖子

我的变量不断将其值更改为 3435973836

每当我运行我的代码时,变量 bookcost 都会改变自己的值: 3435973836 。

它在到达 processingData 函数后执行此操作。我不知道为什么它一直这样做!我已经编写了这个没有函数的程序,它运行良好:( 这是我的第二节编程课,它是在线的,几乎没有教授的支持。

#include <stdio.h>

void inputData(int* inputs,int* booknmbr, int* nmbrpurchased, int* bookcost);
void processingData(int bookcost, int nmbrpurchased, int totalpurch, int costaccu);
void outputInfo(int booknmbr, int nmbrpurchased, int bookcost, int* total);

    int bookcounter = 0;
    int totalpurch = 0;
    int costaccu = 0;
    int totalcostaccu = 0;


int main ()

{
    int booknmbr;
    int nmbrpurchased;
    int bookcost; 
    int bookcounter = 0;
    int cycleRun;
    int total;
    int inputs;

    printf("Run Program? 1 for Yes or -1 …
Run Code Online (Sandbox Code Playgroud)

c

4
推荐指数
2
解决办法
4102
查看次数

错误C2143:语法错误:缺少';' 之前')'

//Program Written By: Andre Chitsaz-zadeh
//Program Written On: 10/7/12
//Program calculates book cost for multiple book orders. 
//Program written using multiple functions.

#include <stdio.h>
#define SIZE 5

void inputData();
void processingData(int costs[]);
int costs[5];

int main ()
{
    inputData();
    processingData(costs);
}

void inputData()
{
    int i = 0;
    printf( "\nPlease enter five products costs.\n" );
    while(i < 5)
    {
       scanf("%d", &costs[i]);
       i = i + 1;
    }
    printf("stuff");
    for (i = 0, i < 5, i++)
        printf("%d\n", costs[i]);
}

void …
Run Code Online (Sandbox Code Playgroud)

c

1
推荐指数
1
解决办法
686
查看次数

为什么这只输出我输入的字符串的第一个字母?

#include <stdio.h>
#include <string.h>

/* Function prototypes */
void wordLength ( char *word );

int main (void)
{
    int choice;
    char word [20];

    printf( "Choose a function by enterting the corresponding number: \n"
        "1) Determine if words are identical\n"
        "2) Count number of words in sentence provided\n"
        "3) Enter two strings to be strung together\n"
        "4) Quit program\n" );
    scanf( "%d", &choice );
    flushall();

    while (choice >= 1 && choice < 4) 
    {
        /* if statements for appropriate user prompt …
Run Code Online (Sandbox Code Playgroud)

c

1
推荐指数
1
解决办法
4032
查看次数

标签 统计

c ×3