Usage of ungetch funtion.

This is a discussion on Usage of ungetch funtion. within the C Programming forums, part of the General Programming Boards category; Hi All, I have been working with java from a long time, I have never worked with C programming language...I ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    4

    Smile Usage of ungetch funtion.

    Hi All,

    I have been working with java from a long time, I have never worked with C programming language...I am from electronics background so was not in touch with these languages...I have started learning C language these days...and I have found it awesome...atleast I will get something to write as a code...not like java where every thing is provided in packages...I have one question I am searching for the usage of ungetch function, I have found definition everywhere but I couldn't found an example which can explain the usage. Kindly help me on this. I hope to get a positive reply from you guys and also kindly let me know a good ID for C. Thanks!!

    Regards,
    Pawan Chopra.

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    It's not a standard C function and I've never seen nor used it.
    That's all I can tell you.
    If I had to guess, I'd say it puts a character back into the stdin stream.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  3. #3
    Complete Beginner
    Join Date
    Feb 2009
    Posts
    312
    Citing from the manpage of ungetc(3):

    int ungetc(int c, FILE *stream);

    [...]

    ungetc() pushes c back to stream, cast to unsigned char, where it is available for subsequent read operations. Pushed-back characters will be returned in reverse order; only one pushback is guaranteed.

    [...]

    Conforming To
    C89, C99.
    The Linux manpages are pretty good. If you need help with common C functions, use "linux man <function>" in Google/linux.die.net or, if you're working in a Unix environment, type "man <function>" in the terminal.

    ungetch() may be anything, definitely not standard. Most commonly, this is some sort of Windows stuff or the ungetch() function from the (n)curses library. Same trick as above also applies here.

    Greets,
    Philip
    Last edited by Snafuist; 03-09-2009 at 08:08 AM.
    All things begin as source code.
    Source code begins with an empty file.
    -- Tao Te Chip

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,275
    ungetch is not ungetc, though the idea is similiar.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Complete Beginner
    Join Date
    Feb 2009
    Posts
    312
    I should stop writing my posts incrementally and instead start a new post...

    Greets,
    Philip
    All things begin as source code.
    Source code begins with an empty file.
    -- Tao Te Chip

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reduce CPU usage
    By patrick22 in forum Windows Programming
    Replies: 9
    Last Post: 07-10-2009, 03:13 PM
  2. Net cpu usage of pthreads?!
    By mynickmynick in forum C++ Programming
    Replies: 15
    Last Post: 09-26-2008, 08:59 AM
  3. Memory usage and memory leaks
    By vsanandan in forum C Programming
    Replies: 1
    Last Post: 05-03-2008, 06:45 AM
  4. Calculating CPU Usage
    By vitaliy in forum Linux Programming
    Replies: 3
    Last Post: 08-21-2005, 10:38 AM
  5. Win2K Limiting CPU Usage?
    By drdroid in forum Tech Board
    Replies: 4
    Last Post: 03-31-2004, 02:08 PM

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