Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char **Expand_maze_row(char **maze, int nrow, int ncol, int *rrow, int *rcol)
- {
- *rrow = *rcol = 0;
- char ** new_maze;
- int new_nrow = 2*nrow -1;
- printf("address of maze = %p\n",maze);
- new_maze = (char**)realloc(maze,new_nrow*ncol*sizeof(char*));
- printf("address of new_maze = %p\n",new_maze);
- new_maze[0] = (char*)malloc(new_nrow*ncol*sizeof(char));
- if(new_maze == NULL|| new_maze[0] == NULL)
- {
- *rrow = *rcol = 0;
- free(new_maze);
- return NULL;
- }
- else{
- int i,j;
- maze = new_maze;
- //assign address
- for(i = nrow; i<new_nrow;i++){
- maze[i] = &(maze[0][i*ncol]);
- }
- //test
- printf("address of maze = %p\n",maze);
- for(i = 0; i<(new_nrow); i++){
- printf("row# = %d\n",i);
- for(j = 0;j<ncol;j++){
- maze[i][j] = i+1;
- printf("%d ",maze[i][j]);
- }
- printf("\n");
- }
- printf("wtf");
- *rrow = new_nrow;
- *rcol = ncol;
- return new_maze;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement