• <tfoot id='l6lrM'></tfoot>

      <small id='l6lrM'></small><noframes id='l6lrM'>

        • <bdo id='l6lrM'></bdo><ul id='l6lrM'></ul>
      1. <i id='l6lrM'><tr id='l6lrM'><dt id='l6lrM'><q id='l6lrM'><span id='l6lrM'><b id='l6lrM'><form id='l6lrM'><ins id='l6lrM'></ins><ul id='l6lrM'></ul><sub id='l6lrM'></sub></form><legend id='l6lrM'></legend><bdo id='l6lrM'><pre id='l6lrM'><center id='l6lrM'></center></pre></bdo></b><th id='l6lrM'></th></span></q></dt></tr></i><div id='l6lrM'><tfoot id='l6lrM'></tfoot><dl id='l6lrM'><fieldset id='l6lrM'></fieldset></dl></div>
        <legend id='l6lrM'><style id='l6lrM'><dir id='l6lrM'><q id='l6lrM'></q></dir></style></legend>
      2. C++:Setenv().Visual Studio 中的未定义标识符

        时间:2023-07-02
            <tbody id='ZHX1r'></tbody>
        • <legend id='ZHX1r'><style id='ZHX1r'><dir id='ZHX1r'><q id='ZHX1r'></q></dir></style></legend>

          <small id='ZHX1r'></small><noframes id='ZHX1r'>

          <tfoot id='ZHX1r'></tfoot>
                <bdo id='ZHX1r'></bdo><ul id='ZHX1r'></ul>

                <i id='ZHX1r'><tr id='ZHX1r'><dt id='ZHX1r'><q id='ZHX1r'><span id='ZHX1r'><b id='ZHX1r'><form id='ZHX1r'><ins id='ZHX1r'></ins><ul id='ZHX1r'></ul><sub id='ZHX1r'></sub></form><legend id='ZHX1r'></legend><bdo id='ZHX1r'><pre id='ZHX1r'><center id='ZHX1r'></center></pre></bdo></b><th id='ZHX1r'></th></span></q></dt></tr></i><div id='ZHX1r'><tfoot id='ZHX1r'></tfoot><dl id='ZHX1r'><fieldset id='ZHX1r'></fieldset></dl></div>

                  本文介绍了C++:Setenv().Visual Studio 中的未定义标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  根据我可以在网上找到的所有文档,看我的代码似乎是正确的.我的 IDE 是 MS Visual Studio Xpress 4 Windows Desktop 2012,它的编译器抛出错误:

                  Error 1 error C3861: 'setenv': identifier not found e:usersownerdocumentsvisual studio 2012projectsproject1project1source1.cpp 18 1 Project1.>

                  帮帮我!!!

                  #include #include #include #include #include #include 使用命名空间标准;int howManyInClass = 0;int main(){long checklength = sizeof(getenv("classSize"))/sizeof(*getenv("classSize"));如果(校验长度== 0){cout<<"请输入您班级的学生人数";cin>howManyInClass;cin.ignore();setenv("classSize", howManyInClass, 1);}};

                  解决方案

                  您可以使用 _putenv() 将字符串参数作为字符串classSize=7;

                  ostringstream classSize;类大小<<类大小="<<howManyInClass;_putenv(classSize.str().c_str());

                  ...或(最好)增强安全性 _putenv_s() 将键和值作为单独的 (const char*) 参数;

                  ostringstream classSize;类大小<

                  Look my code seems to be correct, according to all the documentation I can find online. My IDE is MS Visual Studio Xpress 4 Windows Desktop 2012, and it's compiler is throwing up the error:

                  Error 1 error C3861: 'setenv': identifier not found e:usersownerdocumentsvisual studio 2012projectsproject1project1source1.cpp 18 1 Project1.

                  Help me!!!

                  #include <windows.h>
                  #include <sstream>
                  #include <ostream>
                  #include <cstdlib>
                  #include <iostream>
                  #include <stdlib.h>
                  
                  using namespace std;
                  
                  int howManyInClass = 0;
                  int main(){
                  
                  long checklength = sizeof(getenv("classSize"))/sizeof(*getenv("classSize"));
                  if (checklength==0){
                      cout<<"Please enter the ammount of students in your class";
                      cin>> howManyInClass;
                      cin.ignore();
                      setenv("classSize", howManyInClass, 1);}
                  
                  };
                  

                  解决方案

                  You can either use _putenv() which takes a string parameter as the string classSize=7;

                  ostringstream classSize;
                  classSize << "classSize=" << howManyInClass;
                  _putenv(classSize.str().c_str());
                  

                  ...or (preferably) the security enhanced _putenv_s() that takes the key and the value as separate (const char*) parameters;

                  ostringstream classSize;
                  classSize << howManyInClass;
                  _putenv_s("classSize", classSize.str().c_str());
                  

                  这篇关于C++:Setenv().Visual Studio 中的未定义标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                    <tbody id='s8Ewf'></tbody>
                  <legend id='s8Ewf'><style id='s8Ewf'><dir id='s8Ewf'><q id='s8Ewf'></q></dir></style></legend>

                        <bdo id='s8Ewf'></bdo><ul id='s8Ewf'></ul>
                          <i id='s8Ewf'><tr id='s8Ewf'><dt id='s8Ewf'><q id='s8Ewf'><span id='s8Ewf'><b id='s8Ewf'><form id='s8Ewf'><ins id='s8Ewf'></ins><ul id='s8Ewf'></ul><sub id='s8Ewf'></sub></form><legend id='s8Ewf'></legend><bdo id='s8Ewf'><pre id='s8Ewf'><center id='s8Ewf'></center></pre></bdo></b><th id='s8Ewf'></th></span></q></dt></tr></i><div id='s8Ewf'><tfoot id='s8Ewf'></tfoot><dl id='s8Ewf'><fieldset id='s8Ewf'></fieldset></dl></div>
                        1. <tfoot id='s8Ewf'></tfoot>

                        2. <small id='s8Ewf'></small><noframes id='s8Ewf'>