Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void create_matrix(int nbColumns, int nbRow, char **matrix)
- {
- int i,j;
- matrix = calloc( nbColumns, sizeof(char*));
- if( matrix == NULL ){
- printf("Impossible to allocate");
- exit(EXIT_FAILURE);
- }
- for( i = 0 ; i < nbRow ; i++ ){
- matrix[i] = calloc (nbColumns, sizeof(char*));
- if( matrix[i] == NULL ){
- printf("Impossible to allocate");
- exit(EXIT_FAILURE);
- }
- }
- /* Test filling*/
- for(i = 0; i < nbRow; i++){
- for(j = 0; j < nbColumns; j++){
- matrix[i][j] = 'I';
- }
- }
- //return matrix;
- }
- int main(){
- int i,j;
- char **matrix;
- create_matrix(8,6,matrix);
- //matrix = create_matrix(8,6);
- for(i = 0; i < 6; i++){
- for(j = 0; j < 8; j++){
- printf("%c ",matrix[i][j]);
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement