Trying to write a program that allocates memory as the user enters the number of characters, it doesn't work, where did it go wrong and why? Happy to be corrected.
And yeah, any replacement for getch()?Code:#include<stdio.h> #include<conio.h> int main() { char *c; int n = 0; printf("Enter a string:\n"); while((c[n]=getche())!=0x0D) { c[n+1]=(char *)malloc(sizeof(char)); n++; } printf("%s",c); return 0; }