Sujet : Re: Running an editor from ANSI C
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 07. Jun 2024, 20:39:47
Autres entêtes
Organisation : None to speak of
Message-ID : <87o78cy22k.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Malcolm McLean <
malcolm.arthur.mclean@gmail.com> writes:
[...]
Now to get the $EDITOR variable I will have to modify this function.
>
int main(int argc, char **argv, char **envp)
No, you just have to add `#include <stdlib.h>` and call
`getenv("EDITOR")`, a standard C library function. (It returns a null
pointer if $EDITOR is not set.)
I even mentioned getenv() upthread.
envp lets you see which environment variables are defined, while
getenv() only lets you see an environment variable given its name, but
getenv() is sufficient for $EDITOR.
[...]
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */