Difference between revisions of "User talk:MicheleN"
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
|  (Created page with "Caro MicheleN,  perchè vuoi porre cmpvalue=1?  è inutile.  <syntaxhighlight lang=C> struct word *addword(char *word, struct word *wlist) {   struct word **scan; ...") | m | ||
| Line 29: | Line 29: | ||
| Se scan è NULL esce subito dal ciclo e cmpvalue ha un valore indefinito, ma cmpvalue non viene valutato nell'if che segue (per cortocircuitazione dell'&&). | Se scan è NULL esce subito dal ciclo e cmpvalue ha un valore indefinito, ma cmpvalue non viene valutato nell'if che segue (per cortocircuitazione dell'&&). | ||
| − | Se scan non è NULL, cmpvalue viene assegnato. | + | Se scan non è NULL, cmpvalue viene assegnato. | 
| no? | no? | ||
| [[User:Renzo|Renzo]] ([[User talk:Renzo|talk]]) 10:31, 17 October 2016 (CEST) | [[User:Renzo|Renzo]] ([[User talk:Renzo|talk]]) 10:31, 17 October 2016 (CEST) | ||
Latest revision as of 09:31, 17 October 2016
Caro MicheleN,
perchè vuoi porre cmpvalue=1?
è inutile.
struct word *addword(char *word, struct word *wlist) {
  struct word **scan;
  int cmpvalue /* = 1 useless */;
  for (scan = &wlist;
      *scan != NULL && ((cmpvalue = lenalphacmp(word, (*scan)->word)) > 0);
      scan = &((*scan)->next))
    ;
  if (scan != NULL && cmpvalue == 0)
    (*scan)->count ++;
  else {
    struct word *new = malloc(sizeof(struct word) + strlen(word) + 1);
    if (new) {
      new->next = *scan;
      new->count = 1;
      strcpy(new->word, word);
      *scan = new;
    }
  }
  return wlist;
}
Se scan è NULL esce subito dal ciclo e cmpvalue ha un valore indefinito, ma cmpvalue non viene valutato nell'if che segue (per cortocircuitazione dell'&&). Se scan non è NULL, cmpvalue viene assegnato. no?