I have a weird situation. Suppose a string will be entered as an input. using the getchar() function i count the number of characters the string contains until a new line character is encountered. So i know the size of the string. And then i try to allocate enough memory dynamically to hold that string(itz possible since i know the size). After that i need to read that string again from the console(but the user should enter it only once) and put it in the allocated memory. I just want to know if theres any way i can read an input twice from the console. I know there are other ways i can solve my problem for e.g while i count each character i can write that in a file and later i can read the string from the file anytime i want. But i would like to know if i can read same input twice from the console, and if so how.