Professor give me a homework about malloc, dynamic memory allocate... So He give me some hints about code but I can't understand his code and hints. I think my code needs another 'def' or 'for loop'... Anyway.
question Now I can gets_s some string with pointer. but I can't build. Print like alien language... last of this page I hope this code would be work. for (j=0;j<3;j++) printf("your sentence is %s ", *parray[i])
I tried some of codes with friends. he also can't figure out.. Professor told me This code is for beginner, "IT's easy to solve"
#include<stdio.h>
#include<stdlib.h>
void main() {
char* parray[3];
int i, j;
char str[70]; // temporary save place
for (i = 0; i< 3; i++) { //
printf("sentence, please. : ");
gets_s(str, sizeof(str)); //dynamic memory allocate
parray[i] = (char*)malloc(sizeof(char)**str);
printf("\n");
free(parray[i]);
I hope this code work.
for (j=0;j<3;j++)
printf("your sentence is %s ", *parray[i])