c++ - C++基本内容。什么东西少了???不可能那么明显

Closed. This question needs details or clarity。它当前不接受答案。












想改善这个问题吗?添加详细信息,并通过editing this post阐明问题。

7年前关闭。



Improve this question




谁能帮我了解为什么该程序继续给我错误?我目前正在使用Visual C++ 2008 Express,并且一个接一个地出错。我找不到明显的东西,但请看一看。
# include "stdafx.h"
# include <iostream>
# include <string>
# include <iomanip>
using namespace std;


int main ()
{
    string name;
    int age, amountBeer, amountRootBeer;
    double beer, rootBeer, taxRate, sum, total, cashTendered, change, tax;

    name=“”;
    age=amountBeer=amountRootBeer=0;
    sum=total=cashTendered=change=tax=0.0;
    beer=5.99;
    rootBeer=3.99;
    taxRate=.07;



    cout << “Welcome to BeerMart; where all your beer needs are met. \n\n”
            << “Please enter your name: “;
        getline (cin, name);
    cout << “Hello << name << “.\n”
        << “Please enter your age: “;
        cin >> age;
    if (age > 21)
        {
        cout << “Enter the amount of beers to purchase: “;
        cin >> amountBeer;
        cout << “Enter the amount of root beers to purchase: “;
        cin >> amountRootBeer;

    else
        cout << “Enter the amount of root beers you want to purchase;
        cin >> amountRootBeer;
    }

    cout << “Please wait while we process your order.”;

    sum = (amountBeer * beer) + (amountRootBeer * rootBeer);
    tax = sum * taxRate;
    total = sum + tax;

    system (“pause.exe”);

    if (amountBeer > 0 && amountRootBeer > 0)
    {
    cout << “You ordered “ << amountBeer << “ beer(s) and “ << amountRootBeer<< “ rootBeers.\n\n”
        << “Beer cost $” << beer << “, and root beers cost $” << rootBeer << “.”        << “Your sum is: $“<< sum << “\n”
        << “Your tax is: $” << tax << “\n”
        << “And your total altogether is; $”<< total << endl;
    }
    if (amountBeer == 0 && amountRootBeer > 0)
    {
    cout << “You ordered “ << amountRootBeer<< “ rootBeer(s).\n\n”
        << “Your sum is: $“<< sum << “\n”
        << “Your tax is: $” << tax << “\n”
        << “And your total is; $”<< total << endl;
    }
    if (amountBeer > 0 && amountRootBeer == 0)
    {
    cout << “You ordered “ << amountBeer << “ beer(s)\n\n”
        << “Your sum is: $“<< sum << “\n”
        << “Your tax is: $” << tax << “\n”
        << “And your total is; $”<< total << endl;
    }

    cout << “Please enter the amount of cash tendered: $”;
    cin >> cashTendered;

    change = cashTendered - total;

    cout << “Your change is; $” << change<< “.\n\n”
        << “Have a great day!”;

    return 0;

}

这是错误...
1>------ Build started: Project: CH5HW Simple Beer sales, Configuration: Debug Win32 ------
1>Compiling...
1>CH5HW Simple Beer sales.cpp
1>c:\users\james\documents\visual studio 2008\projects\ch5hw simple beer sales\ch5hw simple beer sales\ch5hw simple beer sales.cpp(16) : error C2065: 'ìî' : undeclared identifier

而这样的例子不胜枚举。

最佳答案

name=“”;

您所有的双引号都不是真正的双引号,请看区别:
name="";

https://stackoverflow.com/questions/19440750/

上一篇:c++ - ISO C++禁止在结构内初始化成员

下一篇:java - 为什么我的代码会导致编译器错误?

相关文章:

c++ - 从 "float"到 "int"的无效缩小转换

c++ - 静态声明二维数组 C++ 作为类的数据成员

windows - 当提供的缓冲区太小时返回哪个 HRESULT?

c++ - 为什么这个带有 C++17 `constexpr if` 的模板化结构无法在 MSVC 上编译?

c# - 哪些 C# 编译器错误未记录?

c++ - 关于范围的最佳变量声明

c++ - 由于我必须忽略的事情,随机 EXC_BAD_ACCESS

c++ - 构建调试输出字符串

c# - Visual Studio 2019版本C#问题

java - 使用 apache.commons.math 库处理 java "cannot find symbol"错误

相关文章:

c++ - "expected ';在返回语句之后,有人可以告诉我我的代码有什么问题吗?

c++ - 声明和初始化struct类型变量时出错

c# - 如果其他语句不起作用

c++ - 为什么我看到 “member function with the same name a

c++ - g++,如何找到出错的地方?

c++ - 无法使用std::pair and constructors [closed]编译代码

c++ - ISO C++禁止在结构内初始化成员

objective-c - ARC 不允许将 'int' 隐式转换为 'id _Nonnull'

java - Java “try without catch”和 “catch without tr

c++ - C++错误,编译器无法识别字符串::push_back [closed]