2023-02-13 10:35:41 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
int cols, rows;
|
|
|
|
|
|
|
|
void insert (char (*content)[cols], char* toInsert) {
|
|
|
|
int i = rows;
|
|
|
|
for (i; i > 0; i --) {
|
|
|
|
strcpy(content[i], content[i - 1]);
|
|
|
|
}
|
|
|
|
strcpy(content[i], toInsert);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main () {
|
2023-02-13 11:08:57 +03:00
|
|
|
cols = 50;
|
2023-02-13 10:35:41 +03:00
|
|
|
rows = 3;
|
|
|
|
|
2023-02-13 11:08:57 +03:00
|
|
|
char (*content)[cols] = malloc(sizeof(char[rows][cols+1]));
|
2023-02-13 10:35:41 +03:00
|
|
|
|
|
|
|
strcpy(content[0], "Test string 1");
|
|
|
|
strcpy(content[1], "Test string 2");
|
|
|
|
|
|
|
|
printf("Array before insert: \n");
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i ++) {
|
|
|
|
printf("%s\n", content[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
insert(content, "test string 0");
|
|
|
|
|
|
|
|
printf("Array after insert: \n");
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i ++) {
|
|
|
|
printf("%s\n", content[i]);
|
|
|
|
}
|
|
|
|
}
|