Sujet : Re: do { quit; } else { }
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 04. Apr 2025, 21:34:44
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250404132935.60@kylheku.com>
References : 1
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-04-04, Thiago Adams <
thiago.adams@gmail.com> wrote:
What do you think of this control block?
>
do
{
FILE f = fopen("file.txt", "r");
>
if (f == NULL) quit; /*goes to else part*/
>
/*success here*/
for (int i =0; i < 10; i++){
...
if (error) quit;
}
>
}
else
{
/*some error*/
}
The else part might need access to some local variables
in the main part.
do {
char *name = calculate_path(PATH_PREFIX "/", name, ".txt");
FILE *f = fopen(...)
if (!f)
quit;
...
}
else
{
printf("unable to open %s\n", name);
...
}
If you make that work, you're creating scope wormholes between
disjoint curly braces, which is not allowed if youre name isn't
Bjarne Stroustrup.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca