Тема: Як заповнити двовимірний динамічний масив стрічкою str = "Programma 1
#include <iostream>
#include "string.h"
#include <cstring>
#include <ctime>
#include <iomanip>
using namespace std;
int main()
{
setlocale(LC_ALL, "rus");
const char* str = "Programma 1";
cout << str << endl;
char** ptrarray = new char* [2];
for (int count = 0; count < 2; count++)
ptrarray[count] = new char[5];
for (int count_row = 0; count_row < 2; count_row++)
for (int count_column = 0; count_column < 5; count_column++)
ptrarray[count_row][count_column] = *str;
/*
size_t len4 = strlen(str);
//pp[size + 1] = new char[len4 + 1];
strcpy_s(*ptrarray, len4 + 1, str);
*/
cout << setw(4) << setprecision(4) << "ptrarray" << endl;
for (int count_row = 0; count_row < 2; count_row++)
{
for (int count_column = 0; count_column < 5; count_column++)
cout << ptrarray[count_row][count_column] << " ";
cout << endl;
}
for (int count = 0; count < 2; count++)
delete[]ptrarray[count];
system("pause");
return 0;
}