4 ms·
> I’m using a custom function for reading lines from a file. [Listing: fgetLine()] It’s probably easier to just use getline(), it does basically the same thing
by mananaysiempre 3y ago
> I’m using a custom function for reading lines from a file. [Listing: fgetLine()]
It’s probably easier to just use getline(), it does basically the same thing and is in POSIX.1-2008[1].
[1] https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/getline.html https://pubs.opengroup.org/onlinepubs/9699919799.2018edition...
- spacechild1 3y agoAFAICT, getline() is not available on Windows, neither with MSVC nor MinGW. The actual solution is to use C++ instead of C :)
- toast0 3y agoThat shouldn't be a big deal for accessing the /proc filesystem as that's also not available on Windows, AFAIK.
- spacechild1 3y agoFair enough!
- deleted 3y ago[deleted]
- adamcc 3y agoYeah, so you are probably right. The custom definition is something that grew out of my response to the following two posts: A general review of the stdlib https://nullprogram.com/blog/2023/02/11/ https://nullprogram.com/blog/2023/02/11/ A review of scanf https://sekrit.de/webdocs/c/beginners-guide-away-from-scanf.html https://sekrit.de/webdocs/c/beginners-guide-away-from-scanf.... Originally I implemented `getLine` (terrible name!) as a way to get multiple lines of input from stdin in a relatively safe way. The implementation borrows almost all of its ideas from the `sekret.de` post. Because I knew the implementation and it was close to hand on my machine, I used it for this version and just swapped out `stdin` for just any old file. Edit: here's the implementation for reference, https://github.com/adammccartney/algorithms/blob/master/libs/adio/adio.c https://github.com/adammccartney/algorithms/blob/master/libs...