Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ungetc(3) [osx man page]

UNGETC(3)						   BSD Library Functions Manual 						 UNGETC(3)

NAME
ungetc -- un-get character from input stream LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdio.h> int ungetc(int c, FILE *stream); DESCRIPTION
The ungetc() function pushes the character c (converted to an unsigned char) back onto the input stream pointed to by stream. The pushed- back characters will be returned (in reverse order) by subsequent reads on the stream. A successful intervening call to one of the file positioning functions (fseek(3), fsetpos(3), or rewind(3)), using the same stream, will discard the pushed-back characters. Only one character of push-back is guaranteed, but as long as there is sufficient memory, an effectively infinite amount of push-back is allowed. If a character is successfully pushed-back, the end-of-file indicator for the stream is cleared. The file-position indicator is decremented by each successful call to ungetc(); if its value was 0 before a call, its value is unspecified after the call. RETURN VALUES
The ungetc() function returns the character pushed-back after the conversion, or EOF if the operation fails. If the value of the argument c character equals EOF, the operation will fail and the stream will remain unchanged. SEE ALSO
fseek(3), getc(3), setvbuf(3), ungetwc(3) STANDARDS
The ungetc() function conforms to ISO/IEC 9899:1990 (``ISO C90''). BSD
June 4, 1993 BSD

Check Out this Related Man Page

UNGETWC(3)						   BSD Library Functions Manual 						UNGETWC(3)

NAME
ungetwc -- un-get wide character from input stream LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdio.h> #include <wchar.h> wint_t ungetwc(wint_t wc, FILE *stream); DESCRIPTION
The ungetwc() function pushes the wide character wc (converted to an wchar_t) back onto the input stream pointed to by stream. The pushed- backed wide characters will be returned by subsequent reads on the stream (in reverse order). A successful intervening call, using the same stream, to one of the file positioning functions fseek(3), fsetpos(3), or rewind(3) will discard the pushed back wide characters. One wide character of push-back is guaranteed, but as long as there is sufficient memory, an effectively infinite amount of pushback is allowed. If a character is successfully pushed-back, the end-of-file indicator for the stream is cleared. RETURN VALUES
The ungetwc() function returns the wide character pushed-back after the conversion, or WEOF if the operation fails. If the value of the argument c character equals WEOF, the operation will fail and the stream will remain unchanged. SEE ALSO
fseek(3), getwc(3) STANDARDS
The ungetwc() function conforms to ISO/IEC 9899:1999 (``ISO C99''). BSD
March 3, 2004 BSD
Man Page

11 More Discussions You Might Find Interesting

1. Programming

reading a single character in C

Can anyone help me????? My problem is that i want to read only one charcter from keyboard. Each time my program waits to press enter or ^d. I don't want that. As soon as i press a charcter it should proceed to next statement in program without pressing enter or ^d. please help... (3 Replies)
Discussion started by: alodha
3 Replies

2. Programming

C program in Unix / Linux - Time differences

Hi Friends, When Iam running c program in redhat linux 7.3 version and PCQ Linux 8.0 version, its taking around 20 seconds. But when Iam running it in HP-UX Release 11i, its taking around 3 minutes. Can anyone throw light on this. Thanks in advance, Praveen. (11 Replies)
Discussion started by: chprvkmr
11 Replies

3. Programming

Replacing words in a file

I'm trying to write a program that will open an existing file supplied by the command line argument and then replace words with "We" or "we" by "I" and "a" or "A" by "The". When I run the program it reads the file, changes the word but re writes it on a new line with only the replaced words not the... (1 Reply)
Discussion started by: adam85
1 Replies

4. Programming

little program error.

I am trying to work this little program, its not working.. int main() { FILE *fp; char *args; pid_t child, exited_pid; int status = 0; *args = "less"; fp = popen("ls", "r"); child =... (4 Replies)
Discussion started by: joey
4 Replies

5. Programming

fopen and open

what is the difference between fopen and open fread and read fwrite and write open and create why this much of functions for the i/o when everything does the same...? What is their major difference? In which case, which is the best to use. :confused:'ed Collins (2 Replies)
Discussion started by: collins
2 Replies

6. Homework & Coursework Questions

How to create one's own pipe in one's own shell?

Good evening, I'm trying to do my own shell and I encountered some issues while creating it. Indeed when I try such a command I have DAUPHINE> DAUPHINE> ls -l | grep terminal > fichier DAUPHINE> cat fichier My shell is named DAUPHINE Whereas I should have: Code: ... (0 Replies)
Discussion started by: AntoineCompagni
0 Replies

7. Programming

Inexplicable buffer crash

I am building a wrapper around fgets, and fighting crashes for no reason I can explain. I have stripped it down as far as I can and it still crashes. #include <stdio.h> #include <stdlib.h> typedef struct { char buf; FILE *fp; int type; } wrap; wrap... (12 Replies)
Discussion started by: Corona688
12 Replies

8. Shell Programming and Scripting

Replacing space with hyphen in a pattern.

I have a huge text file, about 52 GB. In the file, there are patterns like these: ] ] ] ]One can see that there is text within patterns such as and ], and I am only interested in ]. There is text before and after all these patterns too, for example, ''Anarchism''' is a ] that advocates ]... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

9. UNIX for Beginners Questions & Answers

Adding to an array in an external file, and adding elements to it.

I have an array in an external file, "array.txt", which contains: char *testarray={"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};I want to be able to add an element to this array, and have that element display, whenever I call it, without having to recompile... (29 Replies)
Discussion started by: ignatius
29 Replies

10. UNIX for Beginners Questions & Answers

Ncurses status bar

Hi, all, I'm writing a BBS telnet client, and am trying to implement a status bar into it, at the bottom of the screen. I am using NCurses to accomplish this. So far, it appears to be working, that is, upon connecting to BBS, it will display the status bar, and then quickly disappear. ... (5 Replies)
Discussion started by: ignatius
5 Replies

11. UNIX for Beginners Questions & Answers

Displaying every other line in an array.

Hi, I have an array, that works well. But, I want to have it display every other line. Like so, 1, 3, 5, 7, etc, etc. Here is the relevant code: I'm sorry for the pastebin link. For some reason, I can't get the code to format properly with the code tags. code tags work fine... everyone... (4 Replies)
Discussion started by: ignatius
4 Replies