Visual Studio 2017无法识别“系统” [英] Visual Studio 2017 not recognizing "system"

查看:129
本文介绍了Visual Studio 2017无法识别“系统”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从Visual Studio 2015升级到Visual Studio 2017. 当我打开我在2015年编写的程序时,系统和tolower被标记为未定义,我无法获得编译代码。

I recently upgraded from Visual Studio 2015 to Visual Studio 2017.  When I opened a program that I had written in 2015, system and tolower were flagged as undefined and I could not get the code to compile.




#include< iostream>

#include< cstdlib>

#include< cctype> ; $
#include< vector>

#include< iomanip>

使用命名空间std;



#include" CashRegister.h"

#include" Inventory.h"

#include" CustomerDB.h"

#include" Customer.h"

#include" Report.h"

#include" InventoryBook.h"



const string INVENTORY_FILENAME =" inventory.dat";



void cashRegisterMenu(CashRegister& cr,Inventory& inv);

void customerMenu(CustomerDB& cdb);

void inventoryMenu(Inventory& inv);

void reportMenu(Report& rep,Inventory& inv ,CustomerDB& cdb);
$
void displayBookInfo(const InventoryBook * book);
$
void displayCustomerInfo(Customer customer);

InventoryBook makeBook();

InventoryBook editBook(const InventoryBook * book);

Customer makeCustomer();



int main()

{

    字符选择;

     //浮动费用;

     CashRegister cr;

    库存inv(INVENTORY_FILENAME);

    报告代表;

     CustomerDB cdb;



     do

     {

   &NBSP;&NBSP;&NBSP; &NBSP;系统(QUOT; CLS");&NBSP; //未定期

   &NBSP;&NBSP;&NBSP;   cout<< "欢迎使用Serendipity书商POS软件系统"
$
   &NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP; &NBSP;<< endl<<结束;

   &NBSP;&NBSP;&NBSP;   cout<< "选项:" << endl<<结束;

   &NBSP;&NBSP;&NBSP;   cout<< "R - 收银机" <<结束;

   &NBSP;&NBSP;&NBSP;   cout<< "我 - 库存" <<结束;

   &NBSP;&NBSP;&NBSP;   cout<< "C - 客户" <<结束;

   &NBSP;&NBSP;&NBSP;   cout<< "H - 报告" <<结束;

   &NBSP;&NBSP;&NBSP;   cout<< "Q - 退出计划" << endl<<结束;

   &NBSP;&NBSP;&NBSP;   cout<< "输入选项:";
$


   &NBSP;&NBSP;&NBSP;   choice = tolower(cin.get()); //未定期

#include <iostream>
#include <cstdlib>
#include <cctype>
#include <vector>
#include <iomanip>
using namespace std;

#include "CashRegister.h"
#include "Inventory.h"
#include "CustomerDB.h"
#include "Customer.h"
#include "Report.h"
#include "InventoryBook.h"

const string INVENTORY_FILENAME = "inventory.dat";

void cashRegisterMenu(CashRegister& cr, Inventory& inv);
void customerMenu(CustomerDB& cdb);
void inventoryMenu(Inventory& inv);
void reportMenu(Report& rep, Inventory& inv, CustomerDB& cdb);
void displayBookInfo(const InventoryBook* book);
void displayCustomerInfo(Customer customer);
InventoryBook makeBook();
InventoryBook editBook(const InventoryBook* book);
Customer makeCustomer();

int main()
{
    char choice;
    //float cost;
    CashRegister cr;
    Inventory inv(INVENTORY_FILENAME);
    Report rep;
    CustomerDB cdb;

    do
    {
        system("CLS");  // UNDEFINED
        cout << "Welcome to the Serendipity Booksellers POS Software System"
            << endl << endl;
        cout << "Options:" << endl << endl;
        cout << "R - Cash Register" << endl;
        cout << "I - Inventory" << endl;
        cout << "C - Customer" << endl;
        cout << "H - Report" << endl;
        cout << "Q - Quit Program" << endl << endl;
        cout << "Enter option: ";

        choice = tolower(cin.get()); // UNDEFINED




我最终创建了一个新项目并搬家所有文件都进入了新项目。当我这样做时,一切都在新项目中起作用,但所有代码都完全相同。我真的不想为2017年之前在VS的某个版本
中编写的每个程序执行此操作。任何人都对可能发生的事情有任何想法,如何在不创建新的情况下纠正它项目和复制文件?

I ended up creating a new project and moving all the files into the new project. When I did this, everything worked in the new project but all the code is exactly the same. I really do not want to have to do this for every program I had written in some version of VS prior to 2017. Any one have any ideas of what might have happened and how I could have corrected it without creating a new project and copying the files over?







推荐答案

system 函数需要< ;文件stdlib.h>或< process.h>头。尝试在旧项目中添加
'#include< stdlib.h>'

The system function requires the <stdlib.h> or <process.h> header. Try adding ‘#include <stdlib.h>’ in your old project.

也许在新项目中,标题是在"stdafx.h"文件中指定的,这是适合这类事情的地方。


这篇关于Visual Studio 2017无法识别“系统”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆