vector<vector<int>>funktion(char arr[6]){
vector<vector<int>>result;
for(int a{0}; arr[a]!='\0'; a++){
for(int b{0}; arr[b]!='\0'; b++){
if(arr[a]==arr[b]){result[a].push_back(a);}
else{ result[a].push_back(b);}
}
}
return result;
}
Can you be more specific about what you're trying to accomplish?
result is an empty vector, therefore result[a] for any value of a results in undefined behavior.
i have a array in function and i have to compare each other. If its a same charachter, i should a index position of the array put in vector.
Are you aware that vector<vector<int>> is like a 2 dimensional array, technically a ragged array. So you only need an ordinary vector<char>