Skip to main content
Filter by
Sorted by
Tagged with
3 votes
1 answer
86 views

After reading a draft of the c23 standard (n3220), I was trying to gain an understanding of ungetc by writing a simple example. In This Example I: fopen a file named file.txt for updating, either ...
timmy george's user avatar
0 votes
1 answer
128 views

My code is extremely simple, but I figure that's best to figure out what's going on in my program. For some reason, I can't seem to get ungetc() to work properly, nor can I figure out it's purpose. ...
Ratdude's user avatar
  • 93
3 votes
2 answers
217 views

In my current understanding, you're supposed to call ungetc when you want to "un-get" the most recent character that you got from the stream, sort of like reversing the effect of an ...
AJ Tan's user avatar
  • 303
2 votes
1 answer
83 views

This code mix calls to putc() and ungetc() on the same file: #include <stdio.h> int main(int argc, char *argv[]) { FILE *fp; int c; fp = fopen("filetest.txt", "r+&...
MrIo's user avatar
  • 158
1 vote
2 answers
873 views

Say input stream (stdin) has "abc" on it. I want to push back, say, 3 '*' chars to stdin to get something like "***abc". I was trying to use ungetc() (I did ungetc('*', stdin)) for ...
StaticESC's user avatar
0 votes
0 answers
37 views

i'm searching for a long time on net. but no use. please help me. /* getch and ungetch to handle EOF Character In all the ungetch and getch * functions written so far, the buf is declared as char buf[...
neil guo's user avatar
0 votes
0 answers
226 views

Here is the logic what I am trying to do; get input char with fgetc() in the variable named ch, check if not ch is EOF or equal to '\n', increase int variable named counter, then put the variable ch ...
erugersauzu's user avatar
6 votes
1 answer
801 views

ungetc() seems to fail on some characters. Here is a simple test program: #include <stdio.h> int main(void) { int c; printf("Type a letter and the enter key: "); #define TRACE(x) ...
chqrlie's user avatar
  • 153k
0 votes
1 answer
1k views

I'm supposed to read some variables named from "A" to "Z" and then evaluate them. The values in variables are matrices. This is example input: B=[5 2 4; 0 2 -1; 3 -5 -4] E=[-6 -5 -8; -1 -1 -10; 10 0 -...
Tomáš Zato's user avatar
0 votes
1 answer
116 views

I'm porting net-snmp to an embedded platform that only has limited access to the filesystem and I stumbled upon a big problem. There's a part of the core code that uses the ungetc() function, which I ...
mfloris's user avatar
  • 381
-3 votes
4 answers
256 views

I researching about input/output file.Below code relate some functions such as: fgetc(),fgets(),fputs(). i don't know why it does not work exactly as i want.Thank you so much ! Below is my code: #...
Thuan Tran's user avatar
1 vote
2 answers
418 views

I'm a C beginner, I want to call ungetc() twice in a row although I know in regular C it is not permitted. Someone told me I can modify Fflush() to do this job, however I don't know how to do it. ...
yuan wang's user avatar
0 votes
1 answer
349 views

is there a function in php which does something similar to ungetc C? I mean a function that puts a character back onto a stream?
sykatch's user avatar
  • 311
0 votes
1 answer
204 views

I have a code which uses ungetc,and fefo function but i noticed that fefo is not checking for EOF below is my code #include<stdio.h> int main () { FILE *fp; int c; char buffer [200]; ...
user4950013's user avatar
3 votes
2 answers
3k views

I am not understanding how this program works? char c; int i; for(i=1;i<=5;i++) { scanf("%c",&c); printf("%c",c); ungetc(c,stdin); } The output of the program is- character ...
Ravi's user avatar
  • 622
2 votes
2 answers
95 views

I'm trying to read this .txt file: ( 1 2 ( 3 4 ( 5 with this code: #include <stdio.h> int main() { FILE* f = fopen("teste.txt", "r"); int i; char j; while (feof(f) == 0){ ...
Rafael Dias's user avatar
0 votes
2 answers
2k views

Huh!!How shall I put the whole thing in a clear question!!Let me try: I know that the files opened using fopen() are buffered into memory.We use a buffer for efficiency and ease.During a read from ...
Thokchom's user avatar
  • 1,662
2 votes
2 answers
1k views

I think I've run into a problem with Unicode and IO::Handle. It's very likely I'm doing something wrong. I want to get and unget individual unicode characters (not bytes) from an IO::Handle. But I'm ...
Michael's user avatar
  • 8,536
0 votes
3 answers
952 views

I've come across such an example of getword. I understand all the checks and etc. but I have a problem with ungetc. When the c does satisfy if ((!isalpha(c)) || c == EOF)and also doesn't satisfy ...
Peter Cerba's user avatar
0 votes
1 answer
244 views

I am making an extension for an application. My extension uses SolFS and I want to use it to redirect all file traffic to SolFS. To accomplish this I need a bit of help because SolFS has not the ...
user avatar
8 votes
4 answers
2k views

ungetc is only guaranteed to take one byte of pushback. On the other hand, I've tested it on Windows and Linux and it seems to work with two bytes. Are there any platforms (e.g. any current Unix ...
rwallace's user avatar
  • 34.2k
3 votes
3 answers
2k views

Is there a C++ version of ungetc? That is, can I put a character back onto an istream?
fredoverflow's user avatar
2 votes
6 answers
3k views

Some file read (e.g. readlines()) functions in Python copy the file contents to memory (as a list). I need to process a file that's too large to be copied in memory and as such need to use a file ...
user avatar
2 votes
3 answers
2k views

I need to “un-read” characters from an InputStreamReader. For that purpose I wanted to use mark and reset but markSupported returns false for the InputStreamReader class, since it doesn’t maintain an ...
Konrad Rudolph's user avatar