Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int num, i, sum = 0;
- char (*ptr)[SIZE];
- printf("Enter number of elements: ");
- scanf("%d", &num);
- char ptr[num][SIZE];
- ptr = (char (*)[SIZE]) calloc(num, sizeof(char) * SIZE);
- if (ptr == NULL) {
- printf("Error! Memory not allocated!\n");
- exit(0);
- }
- printf("Enter elements...\n");
- for (int i = 0; i < num; ++i) {
- scanf("%s", ptr[i]);
- }
- printf("Elements are:\n");
- for (int i = 0; i < num; ++i) {
- printf("%s\n", ptr[i]);
- }
Add Comment
Please, Sign In to add comment