|
|||
|
Suggestion on Input
I have used lot of scanf in the program. But all inputs are read from user and not from file. In this scenario can I replace my scanf with fgets().Or is it that fgets() function can be used only for reading input from file. If I can use fgets() kindly tell me how should I make fgets() read input from user.
|
| Sponsored Links |
|
|||
|
Yes you can very well replace your scanf with fgets(). fgets() function can be for reading input from file as well getting input from user depending on the needs of the user. As you might know fgets takes three arguments as its input. First is the char pointer, the second one is a integer denoting the maximum number of characters to be read per line and the third one would be a file pointer if the input is a file. For getting input from user change this third argument as stdin and your problem is solved and you can get input from user.
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Validation of user input in QTP | indranilguharoy | Testing Tutorials | 1 | 11-28-2006 10:23 AM |
| C Programming - Managing Input and Output Operations | JobHelper | Career Advice | 0 | 04-15-2006 07:30 AM |
| suggestion needed for GUI design | junchi.tang@gmail.com | Software Patterns | 5 | 05-11-2005 02:43 PM |
| Pattern suggestion for processing similar image types | =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?= | Software Patterns | 0 | 11-18-2004 02:59 PM |
| comp.lang.c Answers to Frequently Asked Questions (FAQ List) | Steve Summit | Tech FAQ | 0 | 06-01-2004 06:00 AM |