小编MWP*_*MWP的帖子

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

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

Error 1 error C3861: 'setenv': identifier not found e:\users\owner\documents\visual studio 2012\projects\project1\project1\source1.cpp 18 1 Project1.

帮我!!!

#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);}

};
Run Code Online (Sandbox Code Playgroud)

c++ environment-variables setenv visual-c++ visual-studio-2012

10
推荐指数
2
解决办法
2万
查看次数