+ 1
Array string pointers in c++
How could I make the array "a" of this code dynamic with pointers? Array "b" will be the same size as array "a". abc --> aabbcc dcab --> ddccaabb https://code.sololearn.com/cGrXtkp5FAm4
3 Respuestas
+ 1
You can use std::array for that:
#include <iostream>
#include <array>
using namespace std;
int main() {
array<string, 3> a = {"a","b","c"};
array<string, a.size()> b;
for (int i=0; i < 3; i++){
b[i] = a[i]+a[i];
}
for (int i=0; i < 3; i++){
cout << b[i] << endl;
}
return 0;
}
+ 1
Victor Cortes thank you!