Queste assegnazioni sono pericolose, attento.codice:char *words[n]; words[0] = "lleaseCall"; words[1] = "hello-hello"; words[2] = "ciaociao"; words[3] = "FIRMAMENTO"; words[4] = "TELEFONAMI"; words[5] = "CHIAMA1ORA"; words[6] = "TELEDOMANI"; words[7] = "telefona domani"; words[8] = "ChiamaOra"; words[9] = "0 OK 1 CALL 99"; words[10] = "PLEASE ball"; words[11] = "1Chiamaora"; words[12] = "00OKOKOKOK"; char *map[10]; map[0] = ""; map[1] = ""; map[2] = "ABC"; map[3] = "DEF"; map[4] = "GHI"; map[5] = "JKL"; map[6] = "MNO"; map[7] = "PQRS"; map[8] = "TUV"; map[9] = "WXYZ";
Dovresti dichiarare quelle matrici const, perchè tu assegni dei valori const char* a dei puntatori non allocati, e non allocandoli non li puoi usare, perchè se provi a fare una modifica su una di quelle stringhe, andresti in segment fault perchè provi a modificare un'area di memoria const.
Se vuoi fare modifiche su quelle stringhe, prima devi allocarle, poi con strcpy copi le stringhe costanti in quelle stringhe allocate.

 
			
			 
			 
					
					
					
						 Rispondi quotando
  Rispondi quotando