Exforsys

Online Training

Suggestion on Input

This is a discussion on Suggestion on Input within the C and C++ forums, part of the Programming Talk category; I have used lot of scanf in the program. But all inputs are read from user and not from file. ...


Go Back   Exforsys > Programming Talk > C and C++

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-15-2007, 07:33 PM
Senior Member
 
Join Date: Apr 2006
Posts: 162
sammy is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-16-2007, 04:39 PM
Senior Member
 
Join Date: Apr 2006
Posts: 122
rachelle is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Validation of user input in QTP indranilguharoy Testing Tutorials 1 11-28-2006 11:23 AM
C Programming - Managing Input and Output Operations JobHelper Career Advice 0 04-15-2006 08:30 AM
suggestion needed for GUI design junchi.tang@gmail.com Software Patterns 5 05-11-2005 03: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 03:59 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit Tech FAQ 0 06-01-2004 07:00 AM


All times are GMT -4. The time now is 12:16 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.