We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

- Prepare
- C
- Arrays and Strings
- Dynamic Array in C
- Discussions

# Dynamic Array in C

# Dynamic Array in C

#### Sort by

recency

#### |

#### 382 Discussions

#### |

Please Login in order to post a comment

## include

## include

/* * This stores the total number of books in each shelf.

/ inttotal_number_of_books;/* * This stores the total number of pages in each book of each shelf. * The rows represent the shelves and the columns represent the books.

/ int*total_number_of_pages;int main() { int query=0,type_of_query=0; int total_number_of_shelves=0; scanf("%d\n",& total_number_of_shelves); scanf("%d\n",&query); total_number_of_books=malloc(sizeof(total_number_of_shelves)); total_number_of_pages=malloc(sizeof(total_number_of_shelves));

}

can anyone help me with this Compiler Message Segmentation Fault Error (stderr) Reading symbols from Solution...done. [New LWP 967146] Core was generated by `./Solution'. Program terminated with signal SIGSEGV, Segmentation fault.

## 0 0x000000000040117f in main ()

1. > # 107 return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());

Is there any way to do this without using malloc function?

Here is my solution: