Vector and for loop

Error: begin was not declared in the scope
The error is in for loop

#include<bits/stdc++.h>

using namespace std;
vector v[1001];

void dfs(int i,vector &v) {
for(int c: v[i])
cout<<c;
}

int main() {

int n,e,a,b;
cin>>n>>e;

vector<bool> vis(n+1,0);
vector<int> v[n+1];
while(e--) {
    cin>>a>>b;
    v[a].push_back(b);
    v[b].push_back(a);
}
dfs(1,v);

}

Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! :slight_smile:

use auto c in dfs function instead of int c in the for loop , that might help.

Okay next time i will keep it in mind and i got the answer but thank you anyway/