|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Jun 2004
Messaggi: 56
|
[c]chiarimento typedef
ciao a tutti
vorrei un chiarimento su queste typedef Codice:
typedef int *poly; typedef poly *der; Se dichiaro una variabile così Codice:
poly p; grazie
__________________
I don't think you trust In, my, self righteous suicide I, cry, when angels deserve to die. |
|
|
|
|
|
#2 |
|
Member
Iscritto dal: Dec 2010
Messaggi: 74
|
poly è un array di interi
der è un array di poly quindi la tua risposta è si sono puntatori
__________________
Scheda Madre : Asus P6T SE | Chipset : Intel X58 | Processore : Intel Core i7 920 @ 2666MHz | Memoria Fisica : 6144MB (3 x 2048 DDR3-SDRAM ) | Scheda Video : ATI Radeon HD 4890 Series | Hard Disk : Seagate STM3500418AS ATA Device (500GB) | DVD-Rom Drive : Optiarc DVD RW AD-7240S | Tipo Monitor : Nissei Sangyo L5AK6 - 15 pollici |
|
|
|
|
|
#3 |
|
Member
Iscritto dal: Jun 2004
Messaggi: 56
|
ma la dichiarazione "poly p" mi crea un puntatore giusto?
oppure devo comunque scrivere "poly *p"?
__________________
I don't think you trust In, my, self righteous suicide I, cry, when angels deserve to die. |
|
|
|
|
|
#4 |
|
Member
Iscritto dal: Dec 2010
Messaggi: 74
|
si è un puntatore
__________________
Scheda Madre : Asus P6T SE | Chipset : Intel X58 | Processore : Intel Core i7 920 @ 2666MHz | Memoria Fisica : 6144MB (3 x 2048 DDR3-SDRAM ) | Scheda Video : ATI Radeon HD 4890 Series | Hard Disk : Seagate STM3500418AS ATA Device (500GB) | DVD-Rom Drive : Optiarc DVD RW AD-7240S | Tipo Monitor : Nissei Sangyo L5AK6 - 15 pollici |
|
|
|
|
|
#5 |
|
Member
Iscritto dal: Jun 2004
Messaggi: 56
|
grazie
un ultimo chiarimento questo programmino dovrebbe stampare gli elementi puntati da p Codice:
int main() {
int k,i,j;
poly p;
printf("inserisci grado del polinomio\n");
scanf("%d\n",&k);
p=calloc((k+1),sizeof(int));
printf("Inserisci i %d coefficenti\n",k+1);
for (i=0;i<=k;i++)
scanf("%d",&p[i]);
for (j=0;j<=k;j++)
printf("%d\n",p[i]);
free(p);
return 0;
}
__________________
I don't think you trust In, my, self righteous suicide I, cry, when angels deserve to die. |
|
|
|
|
|
#6 |
|
Senior Member
Iscritto dal: Oct 2007
Città: Padova
Messaggi: 4131
|
Nell'ultimo ciclo, inizializzi e incrementi 'j' ad ogni iterazione, ma usi 'i' per accedere a 'poly'.
__________________
As long as you are basically literate in programming, you should be able to express any logical relationship you understand. If you don’t understand a logical relationship, you can use the attempt to program it as a means to learn about it. (Chris Crawford) |
|
|
|
|
|
#7 |
|
Member
Iscritto dal: Jun 2004
Messaggi: 56
|
che stupido
prima l'istruzione stava dentro il primo for e spostandola mi sono dimenticato di cambiare i (che figura di m....) grazie mille p.s. Pura curiosità: perchè quando lo eseguo da terminale la seconda printf viene eseguita dopo che ho inserito il primo numero? Vengono tutti memorizzati ma fino a che non digito il primo numero non compare la scritta "inserisci i coefficienti".
__________________
I don't think you trust In, my, self righteous suicide I, cry, when angels deserve to die. Ultima modifica di fenzo : 19-01-2011 alle 12:36. |
|
|
|
|
|
#8 | |
|
Member
Iscritto dal: Dec 2010
Messaggi: 74
|
Quote:
__________________
Scheda Madre : Asus P6T SE | Chipset : Intel X58 | Processore : Intel Core i7 920 @ 2666MHz | Memoria Fisica : 6144MB (3 x 2048 DDR3-SDRAM ) | Scheda Video : ATI Radeon HD 4890 Series | Hard Disk : Seagate STM3500418AS ATA Device (500GB) | DVD-Rom Drive : Optiarc DVD RW AD-7240S | Tipo Monitor : Nissei Sangyo L5AK6 - 15 pollici |
|
|
|
|
|
|
#9 |
|
Member
Iscritto dal: Jun 2004
Messaggi: 56
|
in teoria nel terminale dovrebbe comparire questo (con input: k=3 e 1 2 3 4 come coefficienti)
Codice:
Inserisci grado polinomio 4 inserisci coefficienti 1 2 3 4 1 2 3 4 p.s. uso netbeans su windows 7
__________________
I don't think you trust In, my, self righteous suicide I, cry, when angels deserve to die. |
|
|
|
|
|
#10 |
|
Senior Member
Iscritto dal: Oct 2007
Città: Padova
Messaggi: 4131
|
Codice:
...
printf("inserisci grado del polinomio\n");
scanf("%d\n",&k);
...
__________________
As long as you are basically literate in programming, you should be able to express any logical relationship you understand. If you don’t understand a logical relationship, you can use the attempt to program it as a means to learn about it. (Chris Crawford) |
|
|
|
|
|
#11 | |
|
Member
Iscritto dal: Jun 2004
Messaggi: 56
|
Quote:
__________________
I don't think you trust In, my, self righteous suicide I, cry, when angels deserve to die. |
|
|
|
|
|
|
#12 |
|
Senior Member
Iscritto dal: Oct 2007
Città: Padova
Messaggi: 4131
|
Immagino che quella newline in più veniva passata dalla scanf nel buffer usato per lo standard output, sul quale si appoggia anche la printf per il suo funzionamento.
In pratica era come se con la scanf avessi inserito una riga in più nel buffer, la successiva printf trovando già una riga nel buffer scaricava in output sulla consolle quest'ultima (riga vuota) e memorizzava nel buffer "inserisci coefficienti \n" che restava in attesa di essere scaricato da una chiamata futura (nel tuo caso un'altra scanf). Almeno credo sono andato a ricordi e ragionamento, son quasi 5 anni che non tocco C...
__________________
As long as you are basically literate in programming, you should be able to express any logical relationship you understand. If you don’t understand a logical relationship, you can use the attempt to program it as a means to learn about it. (Chris Crawford) |
|
|
|
|
|
#13 |
|
Member
Iscritto dal: Jun 2004
Messaggi: 56
|
ottima spiegazione, molto chiara
grazie mille dell'aiuto ciao
__________________
I don't think you trust In, my, self righteous suicide I, cry, when angels deserve to die. |
|
|
|
|
|
#14 | |
|
Member
Iscritto dal: Dec 2010
Messaggi: 74
|
Quote:
__________________
Scheda Madre : Asus P6T SE | Chipset : Intel X58 | Processore : Intel Core i7 920 @ 2666MHz | Memoria Fisica : 6144MB (3 x 2048 DDR3-SDRAM ) | Scheda Video : ATI Radeon HD 4890 Series | Hard Disk : Seagate STM3500418AS ATA Device (500GB) | DVD-Rom Drive : Optiarc DVD RW AD-7240S | Tipo Monitor : Nissei Sangyo L5AK6 - 15 pollici |
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 06:58.












sono andato a ricordi e ragionamento, son quasi 5 anni che non tocco C...








