|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Jul 2006
Messaggi: 1568
|
[C] domandina sui puntatori...
domanda semplice semplice..qual'è la differenza tra queste variabili?
1) int *(*c); 2) int **c; 3) int (*c)[10]; |
![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Jul 2006
Messaggi: 1568
|
up...
|
![]() |
![]() |
![]() |
#3 |
Member
Iscritto dal: Apr 2004
Messaggi: 56
|
Boh?
Mi sembra sia qc.del genere
Codice:
int* sono_un_array_di_ptr_a_int[10]; int sono_un_array_di_int[10]; //Array di puntatori int *(*a); //Array di puntatori int **b; //Puntatore ad array di interi int (*c)[10]; //Tanto per chiarire a=sono_un_array_di_ptr_a_int; b=sono_un_array_di_ptr_a_int; c=&sono_un_array_di_int; //E per confondere un po... sono_un_array_di_ptr_a_int[0]=sono_un_array_di_int; |
![]() |
![]() |
![]() |
#4 |
Senior Member
Iscritto dal: Jul 2006
Messaggi: 1568
|
grazie a entrambi! mi erano venuti dei dubbi!
![]() |
![]() |
![]() |
![]() |
#5 | ||
Senior Member
Iscritto dal: Apr 2003
Città: Genova
Messaggi: 4741
|
Quote:
![]() Quote:
Codice:
//e questo? :D sono_un_array_di_array_di_int[0]=sono_un_punt_a_int;
__________________
Jappilas is a character created by a friend for his own comic - I feel honored he allowed me to bear his name Saber's true name belongs to myth - a Heroic Soul out of legends, fighting in our time to fullfill her only wish Let her image remind of her story, and of the emotions that flew from my heart when i assisted to her Fate
|
||
![]() |
![]() |
![]() |
#6 | ||
Senior Member
Iscritto dal: Nov 2005
Città: TO
Messaggi: 5206
|
Quote:
Ecco un esempio di utilizzo: Codice:
int **c; int val = 10; int *pval = &val; c = &pval; printf ("%d\n", **c); /* stampa 10 */ Quote:
Ecco un esempio di utilizzo: Codice:
int (*c)[10]; int arr[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; c = &arr; printf ("%d\n", (*c)[2]); /* stampa 3 */
__________________
Andrea, SCJP 5 (91%) - SCWCD 5 (94%) |
||
![]() |
![]() |
![]() |
#7 |
Senior Member
Iscritto dal: May 2006
Città: Wursteland
Messaggi: 1749
|
e questo ?
![]() Codice:
char *(pippo::*p)(int *)
__________________
Nintendo WIII 4d Turbo Intercooler - Sestium X 666 99,312 GHz - 6.984 Ram Σ(9999) MHz - HDD SATA 97e^(10) bytes 93³ rpm - ATI biberon X900z ∞Mb - Win Eight SP (1 > yours) 16 Valve |
![]() |
![]() |
![]() |
#8 | |
Senior Member
Iscritto dal: May 2006
Città: Wursteland
Messaggi: 1749
|
Quote:
![]() vabbé dai C, C++ cosa cambia ? ![]()
__________________
Nintendo WIII 4d Turbo Intercooler - Sestium X 666 99,312 GHz - 6.984 Ram Σ(9999) MHz - HDD SATA 97e^(10) bytes 93³ rpm - ATI biberon X900z ∞Mb - Win Eight SP (1 > yours) 16 Valve |
|
![]() |
![]() |
![]() |
#9 | |
Senior Member
Iscritto dal: Nov 2005
Città: TO
Messaggi: 5206
|
Quote:
Nella pratica non so se è corretto/valido ... non credo ![]() ![]()
__________________
Andrea, SCJP 5 (91%) - SCWCD 5 (94%) |
|
![]() |
![]() |
![]() |
#10 | |
Senior Member
Iscritto dal: May 2006
Città: Wursteland
Messaggi: 1749
|
Quote:
visto che ci siamo, ho trovato su internet questo: Codice:
int (Pointer::*pmf)(int) = &Pointer::Work; in C basta il nome della funzione per il suo indirizzo, perché in questo caso ci mette la & ? ![]()
__________________
Nintendo WIII 4d Turbo Intercooler - Sestium X 666 99,312 GHz - 6.984 Ram Σ(9999) MHz - HDD SATA 97e^(10) bytes 93³ rpm - ATI biberon X900z ∞Mb - Win Eight SP (1 > yours) 16 Valve |
|
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 11:49.