Why this program have run time error ?
Thanks for oyur help.
Your help is greatly appreciated by me and others.
Code:
// Malloc.c -- String version #include<stdio.h> #include<stdlib.h> int main(int argc, char * argv[]) { int number, loop; char *string; printf("How many number of characters : "); scanf("%d", &number); string = malloc (number); for (loop=0;loop<number;loop++) { scanf("%c", &string[loop]); } for (loop=0;loop<number;loop++) { printf("The string is %s", *(string + loop)); } return 0; } // Why this program got run time error ? // Please correct my mistake and i can learn from mistake
Thanks for oyur help.
Your help is greatly appreciated by me and others.
Comment