- 221
- 18
- CPU
- intel dual core n3050
- Scheda Madre
- asus x540s
- RAM
- 4gb
- GPU
- intel HD
- OS
- Windows 10
C:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int size,i,l;
int rows = 2;
int cols = 5;
int numcols;
int newrows;
int newcols;
char ***table;
//allocate matrix [ROWS][COLUMS][CHARS]
table = malloc(rows * sizeof(char **));
//allocate row matrix that has cols 5
for(i = 0; i < rows; i++)
table[i] = malloc(cols * sizeof(char *));
//allocate cell matrix
for(i = 0; i < rows; i++)
for(l = 0; l < cols; l++){
table[i][l] = malloc(sizeof(char));
table[i][l] = NULL;
}
newrows = 2;
newcols = 2;
table[0][0] = "00";
table[0][1] = "01";
table[0][2] = "02";
table[0][3] = "03";
table[0][4] = "04";
table[1][0] = "10";
table[1][1] = "11";
table[1][2] = "12";
table[1][3] = "13";
table[1][4] = "14";
//modify size add the rows
table = realloc(table,(rows + newrows) * sizeof(char**));
//add memory new rows
for(i = rows; i < (rows + newrows); i++)
table[i] = malloc(cols * sizeof(char *));
//add other columns to all rows
for(i = 0; i < (rows + newrows); i++)
table[i] = realloc(table[i],(cols + newcols) * sizeof(char *));
//add memory new cell
for(i = rows; i < rows + newrows; i++)
for(l = cols; l < cols + newcols; l++)
{
table[i][l] = malloc(sizeof(char));
table[i][l] = NULL;
}
table[2][0] = "20";
table[2][5] = "25";
table[2][6] = "26";
table[3][5] = "35";
table[3][6] = "36";
for(i = 0; i < rows + newrows; i++)
for(l = 0; l < cols + newcols; l++)
{
if( (cols + newcols) - 1 == l)
printf("%s\t\n",table[i][l]);
else
printf("%s\t",table[i][l]);
}
for(i = 0; i < (rows + newrows); i++)
{
//HERE THE SIZE OF table[i] and table[i][l]
numcols = 0;
//from table field
}
return 0;
}