<legend id='Ub4b7'><style id='Ub4b7'><dir id='Ub4b7'><q id='Ub4b7'></q></dir></style></legend>
    <bdo id='Ub4b7'></bdo><ul id='Ub4b7'></ul>
    1. <small id='Ub4b7'></small><noframes id='Ub4b7'>

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

        C++:Setenv().Visual Studio 中的未定义标识符

        时间:2023-10-05

          <bdo id='enoSL'></bdo><ul id='enoSL'></ul>

                <tbody id='enoSL'></tbody>
              <tfoot id='enoSL'></tfoot>

                  <i id='enoSL'><tr id='enoSL'><dt id='enoSL'><q id='enoSL'><span id='enoSL'><b id='enoSL'><form id='enoSL'><ins id='enoSL'></ins><ul id='enoSL'></ul><sub id='enoSL'></sub></form><legend id='enoSL'></legend><bdo id='enoSL'><pre id='enoSL'><center id='enoSL'></center></pre></bdo></b><th id='enoSL'></th></span></q></dt></tr></i><div id='enoSL'><tfoot id='enoSL'></tfoot><dl id='enoSL'><fieldset id='enoSL'></fieldset></dl></div>
                • <legend id='enoSL'><style id='enoSL'><dir id='enoSL'><q id='enoSL'></q></dir></style></legend>
                • <small id='enoSL'></small><noframes id='enoSL'>

                  本文介绍了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 中的未定义标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                      <bdo id='7jSeC'></bdo><ul id='7jSeC'></ul>

                        <small id='7jSeC'></small><noframes id='7jSeC'>

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

                            <tbody id='7jSeC'></tbody>