S
serrand
Could someone tell me a beautiful way to exit from a switch and a loop in one statement ...
without using a goto... and if possible without using an auxiliary variable as i did...
int res;
while (1)
{
res = 0;
if ((i = msgrcv (msqid, &rq_resa, SZ_MsgSrcResa, pid(), 0) == -1)
{
aff_erreurs ("msgrcv", "Error when recieving message : %d", errno);
continue;
}
if (strcasecmp (rq_resa.mess,"admin"))
printf ("Admin d'ont manage bad formatted messages...\n");
else
switch (rq_resa.rep)
{
case 'q':
res = working_q();
manage_error (res);
break;
case 'f':
res = working_f();
manage_error (res);
break;
default:
printf ("This function is not yet implemented...\n");
}
if (res) break;
}
all ideas welcome,
Xavier
without using a goto... and if possible without using an auxiliary variable as i did...
int res;
while (1)
{
res = 0;
if ((i = msgrcv (msqid, &rq_resa, SZ_MsgSrcResa, pid(), 0) == -1)
{
aff_erreurs ("msgrcv", "Error when recieving message : %d", errno);
continue;
}
if (strcasecmp (rq_resa.mess,"admin"))
printf ("Admin d'ont manage bad formatted messages...\n");
else
switch (rq_resa.rep)
{
case 'q':
res = working_q();
manage_error (res);
break;
case 'f':
res = working_f();
manage_error (res);
break;
default:
printf ("This function is not yet implemented...\n");
}
if (res) break;
}
all ideas welcome,
Xavier