|
|
|
![]() |
|
Strumenti |
![]() |
#41 |
Senior Member
Iscritto dal: May 2004
Città: Napoli
Messaggi: 773
|
Dai è fatto sei a cavallo insomma...
![]() Con atoi() hai risolto ![]() Una volta che hai l'intero, puoi usarlo per ciclare.
__________________
If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization. --Gerald Weinberg |
![]() |
![]() |
![]() |
#42 |
Member
Iscritto dal: Jun 2008
Messaggi: 55
|
scusa albi ma non ho capito bene mi potresti spiegare bene cosa devo fare? grazie mille
|
![]() |
![]() |
![]() |
#43 | |
Senior Member
Iscritto dal: May 2004
Città: Napoli
Messaggi: 773
|
Quote:
Tu hai a disposizione il numero preso come stringa (ed è memorizzato in un array di char*, appunto argv). Non sono un drago del C (per cose simile avrei usato gli stringstream C++), ma penso che dovrebbe bastare un: Codice:
int i = atoi(argv[1]); ![]()
__________________
If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization. --Gerald Weinberg |
|
![]() |
![]() |
![]() |
#44 |
Member
Iscritto dal: Jun 2008
Messaggi: 55
|
lo metto prima del for? e poi nel ciclo for lascio i<*num2?
|
![]() |
![]() |
![]() |
#45 |
Member
Iscritto dal: Jun 2008
Messaggi: 55
|
io avevo capito che dovevo fare un a funzione diciamo l'inverso di quello che fa loadlist.. cioè in loadlist il numero lo mette in un vettore, e io devo fare una funzione in modo che da vettore torni intero
forse però ho capito male.. |
![]() |
![]() |
![]() |
#46 |
Senior Member
Iscritto dal: May 2004
Città: Napoli
Messaggi: 773
|
Sì può anche essere un'idea, però avendo il numero sotto forma di char* ti conviene utilizzare quello piuttosto che fare una nuova funzione.
__________________
If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization. --Gerald Weinberg |
![]() |
![]() |
![]() |
#47 |
Member
Iscritto dal: Jun 2008
Messaggi: 55
|
|
![]() |
![]() |
![]() |
#48 |
Member
Iscritto dal: Jun 2008
Messaggi: 55
|
ecco come l'ho modificato
Codice:
int *mult(int *num1, int *num2,const char *argv[]) { int n = getlength2( num1 ) + getlength2( num2 ); int *res=(int *)malloc((n)*sizeof(int)); int i = 0; res=loadlist("0"); *num2 = atoi(argv[2]); for(i = 0; i < *num2; i++) { res = add(res, num1); } return res; } |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 23:48.