小编Jas*_*Lee的帖子

c ++遍历字符串向量

所以我最近发现了地图和矢量的使用,但是,我试图想办法循环一个包含字符串的向量.

这是我尝试过的:

#include <string>
#include <vector>
#include <stdio>

using namespace std;

void main() {
    vector<string> data={"Hello World!","Goodbye World!"};

    for (vector<string>::iterator t=data.begin(); t!=data.end(); ++t) {
        cout<<*t<<endl;
    }
}
Run Code Online (Sandbox Code Playgroud)

当我尝试编译它时,我收到此错误:

cd C:\Users\Jason\Desktop\EXB\Win32
wmake -f C:\Users\Jason\Desktop\EXB\Win32\exbint.mk -h -e
wpp386 ..\Source\exbint.cpp -i="C:\WATCOM/h;C:\WATCOM/h/nt" -w4 -e25 -zq -od    -d2 -6r -bt=nt -fo=.obj -mf -xs -xr
..\Source\exbint.cpp(59): Error! E157: col(21) left expression must be integral
..\Source\exbint.cpp(59): Note! N717: col(21) left operand type is 'std::ostream watcall (lvalue)'
..\Source\exbint.cpp(59): Note! N718: col(21) right operand type is 'std::basic_string<char,std::char_traits<char>,std::allocator<char>> (lvalue)'
Error(E42): …
Run Code Online (Sandbox Code Playgroud)

c++ vector watcom

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

c++ ×1

vector ×1

watcom ×1