Quantcast
Channel: Simple and safe file reader for C - Code Review Stack Exchange
Browsing all 4 articles
Browse latest View live

Answer by JS1 for Simple and safe file reader for C

Not portableFirst of all, I feel that it is nonstandard to use fread() after you've opened the file in text mode. Usually, you use fread() when you open a file in binary mode.That being said, what can...

View Article


Answer by Edward for Simple and safe file reader for C

There are a number of things I see that may help you improve your code.Avoid gotoEvery programmer should understand when and when not to use goto. For useful discussion, history and guidance, see this...

View Article


Answer by Snowbody for Simple and safe file reader for C

This code is not safe, and exhibits undefined behavior. I don't think you've actually tested it. char safe_filename[256]; if (strlen(filename) > 256) { memcpy(safe_filename, filename, 256); }...

View Article

Simple and safe file reader for C

As an exercise to improve my coding ability in C, I have attempted to write a simple and safe file reader. I believe this should be portable as well to major platforms (correct me if I'm wrong). For...

View Article
Browsing all 4 articles
Browse latest View live


Latest Images