C++ std::stringstream未正确将字符串转换为Int

C++ std::stringstream未正确将字符串转换为Int,c++,arrays,char,int,stringstream,C++,Arrays,Char,Int,Stringstream,我正在尝试将CharArrayPtr转换为int格式,我已经成功地做到了这一点 std::string str; for(int i = 0; i < numberofvalues; i++) { str = cmemblock[i]; std::stringstream stream; stream <<str; int n; if (!(stream >

我正在尝试将CharArrayPtr转换为int格式,我已经成功地做到了这一点

    std::string str;

    for(int i = 0; i < numberofvalues; i++)
    {   



        str = cmemblock[i];
        std::stringstream stream;
        stream <<str;
        int n;
        if (!(stream >>n)){

        }

        cout << n<<endl;
        }
我不完全确定为什么会发生这种情况,但我相信我输入的代码没有正确编码,可能无法解释新行

for(int i = 0; i < numberofvalues; i++)

问题就在这里,已修改为正确的值,现在已解决。

我将尝试一下,因为我无法重现问题。请看这里使用您的代码的示例:我不使用C++11,不确定这是否有区别?恐怕是Visual Studio 2010
11
22
33
44
55
66
77
88
99

cout << n;
1
1
1
2
2
2
3
3
3
4
4
4
5
5
5
6
6
6
7
7
7
8
8
8
9
9
9
9
9
9
9
9
9
9
for(int i = 0; i < numberofvalues; i++)