C++for循环跳过cin.get()
C++ for loop skips cin.get()
在这个for循环中,cin.get();每隔一次跳过一次。我不知道为什么要跳过它。如有任何帮助,我们将不胜感激。
代码:
for(Pointer = StartPointer; Pointer < EndPointer; Pointer += MemInfo.RegionSize)
{
VirtualQueryEx(hProc, (LPCVOID)(Pointer), &MemInfo, sizeof(MemInfo));
cout << "MemInfo AllocationBase: " << MemInfo.AllocationBase << endl;
cout << "MemInfo AllocationProtect: " << MemInfo.AllocationProtect << endl;
cout << "MemInfo BaseAddress: " << MemInfo.BaseAddress << endl;
cout << "MemInfo Protect: " << MemInfo.Protect << endl;
cout << "MemInfo RegoinSize: " << MemInfo.RegionSize << endl;
cout << "MemInfo State: " << MemInfo.State << endl;
cout << "MemInfo Type: " << MemInfo.Type << endl;
cout << "MemInfo Size: " << sizeof(MemInfo) << endl;
cout << "Starter pointer is: " << StartPointer << endl;
cin.get();
}
cin.get()之间的输出示例;
MemInfo AllocationBase: 00000000
MemInfo AllocationProtect: 0
MemInfo BaseAddress: 00000000
MemInfo Protect: 1
MemInfo RegoinSize: 65536
MemInfo State: 65536
MemInfo Type: 0
MemInfo Size: 28
Starter pointer is: 0
MemInfo AllocationBase: 00010000
MemInfo AllocationProtect: 4
MemInfo BaseAddress: 00010000
MemInfo Protect: 4
MemInfo RegoinSize: 65536
MemInfo State: 4096
MemInfo Type: 262144
MemInfo Size: 28
Starter pointer is: 0
cin.get()
没有得到您键入的'n'
~
尝试使用,
string str;
getline(cin, str)
而不是cin.get()
或在cin.get()
之后添加getchar()
由于您使用的是Windows:
#include <conio.h>
// .. your other stuff
_getch();
cin.get()
会抓取输入缓冲区中的任何内容(如果你按下回车键、空格键或在键盘上呼吸,它就会有东西),或者EOF
,如果什么都没有,它总是会返回。
相关文章:
- 为什么无论你输入什么,这"while(cin.get(str,3))"只运行一次?
- 使用 cin.get() 初始化字符数组
- 编写 cin.get() 以接收字符数组时出现问题
- 使用 cin.get 读取字符数组
- cin.get()的返回类型
- 在循环中使用 cin.get() 输入字符串
- 为什么 cin.get(char, int) 不会溢出?
- cin.get() 导致"no instance of overloaded function"错误
- 为什么当我输入字符时,这个特定的 cin.get() 语句在C++中不起作用?
- 为什么程序在 cin 之后跳过 cin.get()?
- 如何终止 std::cin.get() 的 ''
- 使用 cin.get() 读取字符
- 无法让我了解 cin.get 和 cout 在这里的工作方式
- cin.get()函数在C 中
- 如何在 c++ 中使用 cin.get() 给出更多数字?
- (m = cin.get())!=EOF&m = cin.get()!=EOF 之间的差异
- 为什么我的应用程序即使我的应用程序也关闭,即使我有cin.get();
- C 使用CIN.Get()暂停此程序
- cin.get() 之后的回车;C++
- 我是否缺少 cin.get() 的东西