Thanks,
Such a dumb error.
But hey, why did you say it's obvious I didn't write it?
Thanks,
Such a dumb error.
But hey, why did you say it's obvious I didn't write it?
@felixthunder
The program could be written much simpler. getopt() is not needed. gcc seems to being used, assuming argv[0] does contain the program name.
argc == 1, use stdin
argc == 2, attempt to open the alleged filename provided as argv[1]
argc > 2, too many arguments, print an error message and exit
For a one .c file program, I would not bother with static functions, not wrong, but not needed
@john.c
"Old teacher"???Maybe you're using an old book. Or have an old teacher.
The age of the teacher is not the problem! Bad, so-called, teachers, instructors, professors, etc... can be of any age, young or old!
Teachers teaching using Turbo C, using K&R as the primary textbook, etc... Yes, it is still being done!
An individual attempting to learn C using painfully inadequate resources, such as, online tutorials, YouTube videos, poorly written online code, etc..., rather than studying from an up to date textbook. Seen this too many times.
BTW, yes, I am an older teacher! ;^)
Yes, I am using old books, most from Kernighan and Rob Pike.
I wrote this program for practicing with stacks, but I have another version that uses arrays: https://pastebin.com/raw/mmi0CCZR
I am also learning about BSD extensions, such as err(3).
In addition to my comments above, rather than using an old book, I would recommend one of the following up to date books on the C Programming Language:
C Programming, A Modern Approach
Author: K. N. King
C Primer Plus, 6th Edition
Stephen Prata
C How to Program, 8/e
Deitel & Deitel
Choose one, study cover to cover, and do all the exercises at the end of each chapter!
I also would recommend sticking to Standard C, and avoid any Non-Standard extensions.I am also learning about BSD extensions, such as err(3).