Array string pointers in c++ | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 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

5th Jun 2022, 11:03 AM
Julmiste Fils Noel
Julmiste Fils Noel - avatar
3 ответов
+ 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; }
6th Jun 2022, 12:16 PM
Victor Cortes
Victor Cortes - avatar
+ 1
Victor Cortes thank you!
6th Jun 2022, 12:17 PM
Julmiste Fils Noel
Julmiste Fils Noel - avatar
9th Jun 2022, 11:04 AM
Daniel Alexis