Don't use gets() function, its vulnerable.
Code: c
fgets(string,sizeof(string),stdin);
And for scanf(),
Code: c
scanf("%[^\n]",string);
Hope that helps you.