Dear Cprogramming.com members and administrator,

Good day to everyone. I programmed this simple C program that accepts an string input and display it on the screen:

Code:
#include<stdio.h>
#include<string.h>
int main()
{
 char name[20];
 printf("Please enter your input string: ");
 gets(name);
 printf("Hello.  Your input is: %s", name);
 getch();
 return 0;
}
It works fine, but I just have certain questions on this like:

1. What necessary C code will I add on this so that my input will be saved on a textfile? Let's
say when I input a string, the string (or maybe the message plus the name) will be
saved to a file named"hello.txt" (I just wonder about this thing because in Java, I have
this is possible using the BufferedWriter class to put my string in a textfile).

2. Can I use a "maximum" length in array without defining it? I mean what if I want more than
20 characters, 40 characters, 60, etc? Or there's no other way but to "maximize"
beforehand the array length of the said array declaration?



Thank you and more power to everyone.


Respectfully yours,

MarkSsquall