Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Didattica > Corsi A - F > Algoritmi e strutture dati > Progetto "FACCIALIBRO"
Pages (28): « First ... « 19 20 21 22 [23] 24 25 26 27 » ... Last »   Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
Bloom
.illuminato.

User info:
Registered: May 2006
Posts: 229 (0.03 al dì)
Location:
Corso:
Anno:
Time Online: 2 Days, 3:14:49 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Joy88
Solito quesito mattutino:

amico* trovaAmico(amico *a, char *nick)
{
amico *app = malloc(sizeof(amico));
app = a;
while(app!=NULL)
{
if (strcmp(nick, app->nome)==0)
return app;
app = app -> next;
}
return NULL;
}
Mi va in segmentation fault (strano eh!) alla strcmp nonostante abbia rincontrollato che il tipo amico abbia veramente un campo nome.. ovviamente char..

se chiedi di stampare il nome dell'amico a lo stampa?

24-02-2009 17:47
Click Here to See the Profile for Bloom Click here to Send Bloom a Private Message Find more posts by Bloom Add Bloom to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Bloom
.illuminato.

User info:
Registered: May 2006
Posts: 229 (0.03 al dì)
Location:
Corso:
Anno:
Time Online: 2 Days, 3:14:49 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Bloom
se chiedi di stampare il nome dell'amico a lo stampa?


Se si fai prima del while:
app->amico=a->amico;

24-02-2009 17:50
Click Here to See the Profile for Bloom Click here to Send Bloom a Private Message Find more posts by Bloom Add Bloom to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Johnny88
I Am Become Death

User info:
Registered: Feb 2008
Posts: 54 (0.01 al dì)
Location:
Corso: Informatica
Anno: 2
Time Online: 14:44:07: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Shaper
Scusate, ho un problema con la funzione strcpy().
Quando compila mi da questo warning:

faccialibro.c:380: warning: incompatible implicit declaration of built-in function 'strcpy'

L'ho usata per esempio in questa funzione:

void status_mod(element *ele, char *str){
strcpy(ele->status, str);
}

Nonostante questo mi sembra che funzioni tutto regolarmente, ma se mi da quel warning qualcosa di storto ci dev'essere...
Anche a voi da questo problema?

Ah, compilo con gcc attraverso NetBeans per Mac


ma string.h l'hai incluso?

25-02-2009 10:40
Click Here to See the Profile for Johnny88 Click here to Send Johnny88 a Private Message Find more posts by Johnny88 Add Johnny88 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Shaper
.consigliere.

User info:
Registered: Sep 2007
Posts: 147 (0.02 al dì)
Location: Milano
Corso: Informatica
Anno: Secondo anno
Time Online: 1 Day, 11:23:27 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Johnny88
ma string.h l'hai incluso?


..ops! :oops:
Chiedo venia, sono proprio fuso! :D

__________________
Eidolon64|Blog

25-02-2009 10:52
Click Here to See the Profile for Shaper Click here to Send Shaper a Private Message Visit Shaper's homepage! Find more posts by Shaper Add Shaper to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Joy88
.consigliere.

User info:
Registered: Jan 2008
Posts: 101 (0.02 al dì)
Location: ~Milano
Corso: Informatica
Anno:
Time Online: 1 Day, 10:27:00: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Bloom
se chiedi di stampare il nome dell'amico a lo stampa?


cmq no, non lo stampa..
Dietro consigli l'ho cambiato in questo modo:

amico* trovaAmico(amico* a, char *nick)
{
adiacenza* temp = malloc(sizeof(adiacenza));
temp->adiacente=a;
printf ("Ecco qui: %s\n", temp->adiacente->nome);
while(temp!=NULL)
{

if (strcmp(temp->adiacente->nome, nick)==0)
return temp->adiacente;
temp = temp -> next;
}
return NULL;
}

Inutile dire che il segfault ora va sulla printf e se la togliessi va sulla strcmp...

__________________
"Amor, ch’a nullo amato amar perdona, mi prese del costui piacer sì forte che, come vedi, ancor non m’abbandona."

*Dante*

25-02-2009 12:14
Click Here to See the Profile for Joy88 Click here to Send Joy88 a Private Message Find more posts by Joy88 Add Joy88 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Johnny88
I Am Become Death

User info:
Registered: Feb 2008
Posts: 54 (0.01 al dì)
Location:
Corso: Informatica
Anno: 2
Time Online: 14:44:07: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

se sviluppi con linux prova ad usare valgrind che ti dice il perchè e il dove di una segmentation fault

25-02-2009 12:50
Click Here to See the Profile for Johnny88 Click here to Send Johnny88 a Private Message Find more posts by Johnny88 Add Johnny88 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Joy88
.consigliere.

User info:
Registered: Jan 2008
Posts: 101 (0.02 al dì)
Location: ~Milano
Corso: Informatica
Anno:
Time Online: 1 Day, 10:27:00: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Uso il dev c in ambiente windows.........

__________________
"Amor, ch’a nullo amato amar perdona, mi prese del costui piacer sì forte che, come vedi, ancor non m’abbandona."

*Dante*

25-02-2009 13:14
Click Here to See the Profile for Joy88 Click here to Send Joy88 a Private Message Find more posts by Joy88 Add Joy88 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Johnny88
I Am Become Death

User info:
Registered: Feb 2008
Posts: 54 (0.01 al dì)
Location:
Corso: Informatica
Anno: 2
Time Online: 14:44:07: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

ah ok, ma voi per il cammino minimo che algoritmo usate?

25-02-2009 13:30
Click Here to See the Profile for Johnny88 Click here to Send Johnny88 a Private Message Find more posts by Johnny88 Add Johnny88 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
darkshadow
Are You From The Past?

User info:
Registered: Jul 2007
Posts: 485 (0.07 al dì)
Location: Milano
Corso: Informatica Magistrale
Anno: 1
Time Online: 13 Days, 13:38:56 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Joy88
cmq no, non lo stampa..
Dietro consigli l'ho cambiato in questo modo:

amico* trovaAmico(amico* a, char *nick)
{
adiacenza* temp = malloc(sizeof(adiacenza));
temp->adiacente=a;
printf ("Ecco qui: %s\n", temp->adiacente->nome);
while(temp!=NULL)
{

if (strcmp(temp->adiacente->nome, nick)==0)
return temp->adiacente;
temp = temp -> next;
}
return NULL;
}

Inutile dire che il segfault ora va sulla printf e se la togliessi va sulla strcmp...


se posti come se sono fatte le strutture amico e adiacenza magari ti posso dare una mano

ciao

__________________
by Ð@rk§h@ÐØw

25-02-2009 14:15
Click Here to See the Profile for darkshadow Click here to Send darkshadow a Private Message Find more posts by darkshadow Add darkshadow to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Bloom
.illuminato.

User info:
Registered: May 2006
Posts: 229 (0.03 al dì)
Location:
Corso:
Anno:
Time Online: 2 Days, 3:14:49 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Joy88
cmq no, non lo stampa..
Dietro consigli l'ho cambiato in questo modo:

amico* trovaAmico(amico* a, char *nick)
{
adiacenza* temp = malloc(sizeof(adiacenza));
temp->adiacente=a;
printf ("Ecco qui: %s\n", temp->adiacente->nome);
while(temp!=NULL)
{

if (strcmp(temp->adiacente->nome, nick)==0)
return temp->adiacente;
temp = temp -> next;
}
return NULL;
}

Inutile dire che il segfault ora va sulla printf e se la togliessi va sulla strcmp...


Prova dopo temp->adiacente=a;
temp->adiacente->nome=a->nome
e poi la printf

25-02-2009 15:17
Click Here to See the Profile for Bloom Click here to Send Bloom a Private Message Find more posts by Bloom Add Bloom to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Gehur
.grande:maestro.

User info:
Registered: Apr 2006
Posts: 519 (0.07 al dì)
Location: Milano
Corso: Informatica
Anno:
Time Online: 3 Days, 0:41:42 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

allora ragazzi, andiamo con calma..ripartiamo da zero...se il seg faul è sulla printf vuol dire che temp->adiacente->nome ha contenuto random, oppure che temp->adiacente ha contenuto random, quindi

io come inizio stamperei a ed il suo contentuto (presumo a->nome)

poi se levi la printf, ti entra nel ciclo while? ti esegue l'if?? presumo di si visto che dici l'errore ti si sposterebbe sulla strcmp..cioè sul contenuto di temp->adiacente..

25-02-2009 16:27
Click Here to See the Profile for Gehur Click here to Send Gehur a Private Message Find more posts by Gehur Add Gehur to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Gehur
.grande:maestro.

User info:
Registered: Apr 2006
Posts: 519 (0.07 al dì)
Location: Milano
Corso: Informatica
Anno:
Time Online: 3 Days, 0:41:42 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Johnny88 io uso visita in ampiezza di un grafo..

25-02-2009 16:30
Click Here to See the Profile for Gehur Click here to Send Gehur a Private Message Find more posts by Gehur Add Gehur to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Joy88
.consigliere.

User info:
Registered: Jan 2008
Posts: 101 (0.02 al dì)
Location: ~Milano
Corso: Informatica
Anno:
Time Online: 1 Day, 10:27:00: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Posto le mie strutture amico e adiacenza.. e confido nel tuo aiuto darkshadow!!
typedef struct adiacenza
{
struct amico* adiacente;
struct adiacenza* next;
struct adiacenza* prev;
} adiacenza;

typedef struct amico
{
char *nome;
struct adiacenza *adiacenza;
struct amico *next,*prev;
int visited;
int stato_amicizia;
}amico;

__________________
"Amor, ch’a nullo amato amar perdona, mi prese del costui piacer sì forte che, come vedi, ancor non m’abbandona."

*Dante*

25-02-2009 19:28
Click Here to See the Profile for Joy88 Click here to Send Joy88 a Private Message Find more posts by Joy88 Add Joy88 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Johnny88
I Am Become Death

User info:
Registered: Feb 2008
Posts: 54 (0.01 al dì)
Location:
Corso: Informatica
Anno: 2
Time Online: 14:44:07: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Gehur
Johnny88 io uso visita in ampiezza di un grafo..


Ma sei sicuro che la visita in ampiezza possa calcolare un cammino minimo?

25-02-2009 19:32
Click Here to See the Profile for Johnny88 Click here to Send Johnny88 a Private Message Find more posts by Johnny88 Add Johnny88 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Gehur
.grande:maestro.

User info:
Registered: Apr 2006
Posts: 519 (0.07 al dì)
Location: Milano
Corso: Informatica
Anno:
Time Online: 3 Days, 0:41:42 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

be certo..la visita in ampiezza calcola il cammino minimo da un nodo a tutti gli altri nodi raggiungibili..ma non hai il libro??

25-02-2009 20:00
Click Here to See the Profile for Gehur Click here to Send Gehur a Private Message Find more posts by Gehur Add Gehur to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 14:09.    Post New Thread    Post A Reply
Pages (28): « First ... « 19 20 21 22 [23] 24 25 26 27 » ... Last »   Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.222 seconds (69.42% PHP - 30.58% MySQL) con 24 query.