i guess iβve started taking it upon myself to educate a young cis lady about c programming. luckily she is using a mac.
on mac, you can open up your βTerminal.appβapplication and run:
$ echo "#!/bin/sh\
man -t $1 $2 | open -f -a System/Applications/Preview.app\
" > pages
$ chmod 755 pages
$ ./pages c89
to view a readily accessible pdf of the c89 compiler on Preview.app, and
$ ./pages 3 atof
to view a pdf for the function βatof()β in the standard c89 header βstdlib.hβ
( it also helps to de-βmanβ your command line interface a bit )
but hereβs an example program i wrote as βgreater.cβ. :
#include<stdio.h>
#include<stdlib.h>
int main(const int argc, const char **argv){
Β const double x = (*++argv != NULL ? atof(*argv) : (double)0);
Β const double y = (*++argv != NULL ? atof(*argv) : (double)0);
Β printf("%lf\n",(x > y ? x : y));
Β return 0;
}
Comments
Displaying 1 of 1 comments ( View all | Add Comment )
ππππππππΏπΎ
in my eyes, using βint argc and char **argvβ for user input is far less fault-prone than using βscanf()β.
honestly, just donβt use scanf if you can avoid having to use it, but if you have to get user input from stdin while the program is running in real-time, like if youβre writing a REPL, then maybe using fgets() over an algorithm with a string-queue would be much better
Report Comment
i honestly get really pissed at people who teach beginners to write lines of code read user input with scanf(), because theyβre teaching beginners that they should use scanf when they really shouldnβt, and it will sadly stick with a lot of programmers for far too long.
donβt use scanf.
donβt teach people to use scanf
by ππππππππΏπΎ; ; Report