Hi,
I am trying to ask the user for an input (a string), then store the input in a string variable with the same length of the string in-putted.
Is this possible? I have some code below but this requires the user to input the string twice.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
int num_char=1, i;
char holder=' ';
char *string;
printf("Please enter a sentence:\n");
while (holder != '\n'){
	holder = getchar();
	printf("%c ",holder);
	num_char++;
}
printf("\n%d\n",num_char);
string = (char*) malloc(sizeof(char)*num_char);
gets(string);
for (i=0; i<num_char; i++){
	printf("%c",string);}
return 0;
}
Thanks

Sef