Created
September 9, 2019 16:13
-
-
Save ChlorUpload/ea79511c79be7818ab02ffd3c1f71797 to your computer and use it in GitHub Desktop.
double pointer exercise program ( visual studio 2019 )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _CRT_SECURE_NO_WARNINGS | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
unsigned n; | |
scanf("%u", &n); | |
char* str = (char*)malloc(sizeof(char) * (n + 1)); | |
scanf_s("%s", str, n + 1); | |
char** arrs = (char**)malloc(sizeof(char*) * (n + 1)); | |
for (int i = 0; i <= n; ++i) | |
{ | |
arrs[i] = (char*)malloc(sizeof(char) * (i + 1)); | |
arrs[i][i] = '\0'; | |
for (int j = 0; j < i; ++j) | |
arrs[i][j] = str[j]; | |
} | |
for (int i = 0; i <= n; ++i) | |
{ | |
printf("%s\n", arrs[i]); | |
} | |
for (int i = 0; i <= n; ++i) | |
free(arrs[i]); | |
free(arrs); | |
free(str); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment