ERLEDIGT
JA
JA
ANTWORTEN
2
2
ZUGRIFFE
2236
2236
EMPFEHLEN
-
Hallo Leute! Ich schreibe ein Testprogramm in C zu IP Forwarding. Als Compiler benutze ich MS Visual Studio 2008 Professional. Habe aber ein Problemm mit den Pointern. Hier ist ein kleiner Auszug aus dem Programm.
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#include <stdio.h> #include <stdlib.h> #define TABLE_LENGTH 32772 //Definition Small Search Group struct ssg1 { unsigned int suffix, next_hop; unsigned char flag, length; }; //Definition Hash Table struct hash_table1 { unsigned int identifier, collision_pointer; unsigned char ssg_size; struct ssg1 *ssg_pointer; }; //Programmbegin void main() { int i, j; unsigned char hash_length; unsigned int hash_result; struct ssg1 *ssg; struct hash_table1 hash_table[2*TABLE_LENGTH]; hash_result=2; hash_table[hash_result].ssg_size=1; hash_table[hash_result].ssg_pointer=(struct ssg1 *) calloc(16,sizeof(struct ssg1 )); if (hash_table[hash_result].ssg_pointer=0) { printf("Not enough memory"); exit(1);} ssg=hash_table[hash_result].ssg_pointer; //Initialisierung SSG for (j=0; j<16; j++) { ssg->flag=0; ssg->length=0; ssg->next_hop=0; ssg->suffix=0; ssg++; } printf("Done"); getchar(); }
an der Stelle "ssg->flag=0" sagt mir der Debuger "Unhandled exception at 0x00843752 in test.exe: 0xC0000005: Access violation writing location 0x00000008." Weiss jemand einen Rat? Noch eine Frage wäre, ob ich direkt über hash_table[hash_result].ssg_pointer in z.B. Flag was reinschreiben kann? Bei hash_table[hash_result].ssg_pointer->flag=0 bekomme ich die selbe Fehlermeldung. Bin neu im Forum, wenn ich was falsch geschrieben habe, entschuldige ich mich im voraus.Geändert von nickoff (29.03.08 um 21:55 Uhr)
-
Du setzt den Zeiger auf 0 und prüfst ihn nicht.
Wenn in der Schleife nun auf den nullpointer zugregriffen wird, geht das natürlich nicht.
Ich denke mal du willst == anstatt = benutzen
Best wishes
FBIagentGeändert von FBIagent (30.03.08 um 12:06 Uhr)
Don't blame people for bugs. Work together to make things better. No
finger pointing! Not ever! A good rule is to Never Assume An Attack.
If you find yourself getting angry, assume it's a misunderstanding, not an
attack.
-
super! danke! das war der Fehler.
Ähnliche Themen
-
access violation
Von alice in wunderlan im Forum Cinema 4DAntworten: 3Letzter Beitrag: 26.02.10, 12:51 -
Access Violation bei Wiederholungsabfrage
Von VB6-User231 im Forum VisualStudio & MFCAntworten: 3Letzter Beitrag: 05.02.10, 13:25 -
Unmanaged DLL Access Violation?
Von engelmarkus im Forum .NET CaféAntworten: 4Letzter Beitrag: 15.05.09, 22:58 -
Access Violation!?
Von shader09 im Forum C/C++Antworten: 3Letzter Beitrag: 03.03.08, 15:39 -
access vîolation
Von derGugi im Forum Delphi, Kylix, PascalAntworten: 2Letzter Beitrag: 15.04.03, 16:10





Zitieren
Login






