Re: goto
- From: cri@xxxxxxxx (Richard Harter)
- Date: Thu, 16 Jul 2009 19:56:59 GMT
On Thu, 16 Jul 2009 06:29:12 +0200, "io_x" <a@xxxxxxxxxxx> wrote:
yesterday i wrote one routine, so you can examine that:
[snip original code]
Here is a rewrite that eliminates the gotos and the "silly" macros. There
is no guarantee that it (or the original code) is correct. Some people
have a twisted panties problem with do/while blocks. In this case they are
easily recoded and I leave the joy of doing so to anyone who might care.
int getStdI(char* tmp, int sztmp)
{
int i, r, c;
char *a;
if(tmp==0||sztmp<=1) return 0;
*tmp=0; c=0;
do {
Fflush_m(stdout_m);
i=fgets_m(tmp, sztmp, stdin_m); /* i=strlen(tmp) */
if((i<=0) || (i+1==sztmp)) { /* errore di input */
if(++c>=3) return 0;
P("Stringa Troppo lunga o Errore hardware\nreturneinserire > ");
Fflush_m(stdin_m);
continue;
}
} while(0);
a=tmp+i; r=i;
do {
if(a<=tmp) break;
--a;
if (!((*a==10)||(*a==13)||(Isspace_m(*a))) break;
*a=0; --r;
} while(1);
return r;
}
Richard Harter, cri@xxxxxxxx
http://home.tiac.net/~cri, http://www.varinoma.com
If I do not see as far as others, it is because
I stand in the footprints of giants.
.
- Follow-Ups:
- Re: goto
- From: Ben Bacarisse
- Re: goto
- References:
- Re: goto
- From: io_x
- Re: goto
- Prev by Date: Re: linking c++ code with c library
- Next by Date: Re: goto
- Previous by thread: Re: goto
- Next by thread: Re: goto
- Index(es):
Relevant Pages
|
Loading