好久没写c++了,之前学的都还给老师了,今天第一次复习就遇到了这个问题
问题: VS2013提示cout cin为未声明的标识符
原始代码为:
#include "stdafx.h"
#include <windows.h>
#include<iostream.h>
int _tmain(int argc, _TCHAR* argv[])
{
SYSTEM_INFO si;
GetSystemInfo(&si);
printf("The page size for this system is %u bytes./n", si.dwPageSize);
int a;
cin >> a ;
return 0;
}
报错未定义标识符cin
解决:
在头文件中增加声明:
using namespace std;
增加后代码为:
#include "stdafx.h"
#include <windows.h>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
SYSTEM_INFO si;
GetSystemInfo(&si);
printf("The page size for this system is %u bytes./n", si.dwPageSize);
int a;
cin >> a ;
return 0;
}
1.cin cout在std namespace标准命名空间里,必须先声明
2.将#include<iostream.h>非标准输入输出流 改为 #include<iostream>的标准输入输出流