小编Meg*_*ney的帖子

实际初始化的未初始化的局部变量?

所以我正在编写一个处理输入文件中的值的程序.我的变量包括总数,taxtotal,小计等等.它们已经被声明和初始化了,但是我收到两条错误消息:"未初始化的局部变量'小计'使用过'"和变量"taxtotal"相同. 源代码:

#include "stdafx.h"
#include<stdio.h>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main()
{

    ifstream shoppingBasketFile;
    shoppingBasketFile.open("HW3_Data.txt");
    bool isTaxed = false;
    char taxValue = 0;
    char inPrice[64];
    char name[128];
    double price, taxtotal, subtotal, total = 0;

    if (shoppingBasketFile.is_open())
    {
        // display the header info:
        cout << "o  Thank you for shopping at StuffMart" << endl;
        cout << setw(3) << left << "o  "
            << setw(20) << left << "Item"
            << setw(12) << "Unit Price"
            << …
Run Code Online (Sandbox Code Playgroud)

c++ visual-c++

-3
推荐指数
2
解决办法
591
查看次数

标签 统计

c++ ×1

visual-c++ ×1