Re: Every sufficiently competent C programmer knows

Liste des GroupesRevenir à c theory 
Sujet : Re: Every sufficiently competent C programmer knows
De : rjh (at) *nospam* cpax.org.uk (Richard Heathfield)
Groupes : comp.theory
Date : 12. Mar 2025, 11:00:50
Autres entêtes
Organisation : Fix this later
Message-ID : <vqrm0i$2frof$7@dont-email.me>
References : 1 2 3 4 5 6 7
User-Agent : Mozilla Thunderbird
On 12/03/2025 09:49, Mikko wrote:
On 2025-03-11 18:23:24 +0000, Richard Heathfield said:
 
int rhc(unsigned int i)
{
   typedef int(*pf)(unsigned int);
   pf arr[3] = {rha, rhb, rhc};
   return arr[i % 3];
 The return instruction has wrong type.
Good spot, but no, it's fine. The bug is elsewhere. That line should read:
return arr[i % 3](i);
arr is of type int(*)(unsigned int)[3]
arr[i % 3] is of type int(*)(unsigned int)
arr[i % 3](i) is a function call returning int
--
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

Date Sujet#  Auteur
20 Apr 26 o 

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal