feof Questions

6

Solved

What is wrong with using feof() to control a read loop? For example: #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { char *path = "stdin"; FILE *fp...
Postliminy asked 25/3, 2011 at 11:42

5

Solved

I opened a file, the stream is found at the address of pointer ptr. I am attempting to see whether or not a file is blank. Using the following if (fgetc(ptr) != EOF) works as expected. When the ...
Calx asked 22/3, 2016 at 20:38

2

Solved

Upon looking at the ISO C11 standard for fgets §7.21.7.2, 3, the return value is stated regarding the synopsis code: #include <stdio.h> char *fgets(char* restrict s, int n, FILE* restrict str...
Valedictory asked 23/7, 2017 at 4:33

5

Solved

I'm a beginner in C++ and trying to better understand feof(). I've read that feof() flag is set to true only after trying to read past the end of a file so many times beginners will read once more ...
Rhiamon asked 12/5, 2016 at 17:40

3

Solved

I am writing a C library that reads a file into memory. It skips the first 54 bytes of the file (header) and then reads the remainder as data. I use fseek to determine the length of the file, and t...
Affectation asked 2/10, 2008 at 19:2

3

Solved

I've written this minishell but I'm not sure I'm making a correct control of the errors. I know fgets can return feof and ferror (http://www.manpagez.com/man/3/fgets/) but I don't know how to...
Meninges asked 12/2, 2014 at 9:41

1

I am encoutering this problem. I am using while loop to scan string of numbers and need to end scanning and start proceeding the rest of my program. I just can't figure out, how to flush the stdin ...
Olly asked 10/11, 2013 at 11:43

2

Solved

Does feof() checks for eof for the current position of filepointer or checks for the position next to current filepointer? Thanks for your help !
Inhibitor asked 9/9, 2012 at 8:29

2

I need to input coordinates into an array until EOF is encountered, but something is wrong in my code. I used ctrl+Z, ctrl+D int main() { int x[1000],y[1000]; int n=0,nr=0,a,b,i; printf("Enter ...
Mcdermott asked 11/11, 2011 at 13:32

2

Solved

Here is the code that I am using: if (!($fp = fsockopen('ssl://imap.gmail.com', '993', $errno, $errstr, 15))) echo "Could not connect to host"; $server_response = fread($fp, 256); echo $server_re...
Lantana asked 4/5, 2012 at 13:12

3

Solved

I come from a C and C++ background but also play with some web stuff. All us C folks (hopefully) know that calling feof on a FILE* before doing a read is an error. This is something that stings new...
Palma asked 13/7, 2010 at 16:57

3

Solved

On another question, Jerry Coffin pointed out the following: It's (probably) not really related to your question, but while (!feof(fileptr)){ is pretty much a guaranteed bug. I figured I would...
Getz asked 19/10, 2009 at 12:11
1

© 2022 - 2024 — McMap. All rights reserved.