Sujet : Re: Command Languages Versus Programming Languages
De : rweikusat (at) *nospam* talktalk.net (Rainer Weikusat)
Groupes : comp.unix.shell comp.unix.programmer comp.lang.miscDate : 22. Nov 2024, 16:52:41
Autres entêtes
Message-ID : <87zflrs1ti.fsf@doppelsaurus.mobileactivedefense.com>
References : 1 2 3 4 5 6
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Rainer Weikusat <
rweikusat@talktalk.net> writes:
[...]
Something which would match [0-9]+ in its first argument (if any) would
be:
>
#include "string.h"
#include "stdlib.h"
>
int main(int argc, char **argv)
{
char *p;
unsigned c;
>
p = argv[1];
if (!p) exit(1);
while (c = *p, c && c - '0' > 10) ++p;
This needs to be
while (c = *p, c && c - '0' > 9) ++p