use function to call scanf()

This is a discussion on use function to call scanf() within the C Programming forums, part of the General Programming Boards category; is it possible to accept values via a function without directly using scanf(). if yes plz tel how. plz look ...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    50

    use function to call scanf()

    is it possible to accept values via a function without directly using scanf(). if yes plz tel how. plz look at the attachment, wats the error in it? how can i achieve the aforesaid intention.

  2. #2
    THANK YOU KINDLY SIR Phenax's Avatar
    Join Date
    Mar 2011
    Posts
    74
    • Your file ends in .cpp. You are asking for help in the C subforum.
    • You can only return one variable or value. You are attempting to return multiple variables in your scan() function.
    • The pointers in your scan() function are dangling pointers. You never initialized them.
    • Your program uses the scanf function directly.
    • There are multiple ways to scan in data. For example, using gets. But gets is not a "safe" function.
    • Using "goto" when not needed is generally seen as a poor programming habit.
    • conio.h isn't standard C. It's better to just use getchar to keep the console open.
    Last edited by Phenax; 04-07-2011 at 09:16 PM.
    Quote Originally Posted by Plato
    Never discourage anyone...who continually makes progress, no matter how slow.

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    50
    but how can it be done??

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,628
    Yes, by using say, fscanf or sscanf, or by parsing the input yourself.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL DC Buffer Renders slow
    By Lane the Great in forum Game Programming
    Replies: 10
    Last Post: 01-07-2011, 06:52 PM
  2. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 06:18 AM
  3. Loading files with a function call
    By ulillillia in forum C Programming
    Replies: 6
    Last Post: 04-10-2007, 07:19 PM
  4. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 12:03 PM
  5. Replies: 3
    Last Post: 03-04-2005, 01:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21