Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
914 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  pb!!!! unhandled exception..... : access violation

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

pb!!!! unhandled exception..... : access violation

n°301596
vandekerpu​t
hooohhi'm'bohéé !!!!
Posté le 04-02-2003 à 23:49:37  profilanswer
 

:cry:  
le C c'est caca!
ça marche pa!
c'est bon que pour les chats!
 :sweat:  
 
 
 :hello:  
c'est je pense une erreur d'alloc mémoire, mais je sé pa comen l'empecher :  
 
struct client
{ char* nom;
struct adresse adr;
};
 
struct client *cl;
 
void enregistrer()
{
 int i = 0;
 while(cl[i].nom != "" ) // ça plante là!!!!!!
 {i++;}

mood
Publicité
Posté le 04-02-2003 à 23:49:37  profilanswer
 

n°301611
fykman
Errare Humanum Est
Posté le 04-02-2003 à 23:53:01  profilanswer
 

Vandekerput a écrit :

:cry:  
struct client *cl;
 
void enregistrer()
{
 int i = 0;
 while( cl[i] .nom != "" ) // ça plante là!!!!!!
 {i++;}


 
C'est quoi ce delire, tu declare un pointeur sur ta structure client et tu essayes d'acceder a un tableau de client.
Si t'a besoin d'un tableau il faut allouer la memoire avec malloc...


Message édité par fykman le 04-02-2003 à 23:53:41
n°301626
vandekerpu​t
hooohhi'm'bohéé !!!!
Posté le 04-02-2003 à 23:57:04  profilanswer
 

fykman a écrit :


 
C'est quoi ce delire, tu declare un pointeur sur ta structure client et tu essayes d'acceder a un tableau de client.
Si t'a besoin d'un tableau il faut allouer la memoire avec malloc...


 
!hop!hop!hop! t'énerve pa  :o  
je sui un débutant en C, cé mon 2ème prog, c'est la première foi ke j'utilise les pointeurs...bref j'sui une bille, et en plus j'ai rien compri ton explication...
j'ai fais ça avant, mais ça marche po
 
cl[i].nom = (char*)malloc(255);
cl[i].adr.rue = (char*)malloc(255);
cl[i].adr.ville = (char*)malloc(255);

n°301628
jo_popo
aka Kalonji
Posté le 04-02-2003 à 23:57:56  profilanswer
 

:whistle:  
 
 :hello:


---------------
Tout ce qui monte redescend un jour ...
n°301640
vandekerpu​t
hooohhi'm'bohéé !!!!
Posté le 04-02-2003 à 23:59:53  profilanswer
 


vien pa pourrir mon tomic !!!!!!!
 :cry:  :cry:  :cry:  
vilain monsieur, t'es méchant...  :cry:  :cry:  

n°301656
fykman
Errare Humanum Est
Posté le 05-02-2003 à 00:02:50  profilanswer
 


ok je me calme ,  ;)  
 
essaye ca :
 
void enregistrer()  
{  
int i = 0;
 
n = ?? //le nombre de client que veux pouvaoir rentrer
cl = (client)malloc(n*sizeof(client));
 
while(cl[i].nom != "" ) // ça plante là!!!!!!  
{i++;}
.....
.....
free(cl);
}
 
mais je suis pas sur de la syntaxe...

n°301664
Clie
Posté le 05-02-2003 à 00:05:15  profilanswer
 

Tu declare un pointeur sur une structure client et après t'essai d'acceder sous la forme d'un tableau, ca po pas marcher

n°301665
vandekerpu​t
hooohhi'm'bohéé !!!!
Posté le 05-02-2003 à 00:05:20  profilanswer
 

ok, j'essay et j'te di
 :jap:

n°301674
fykman
Errare Humanum Est
Posté le 05-02-2003 à 00:06:54  profilanswer
 

Vandekerput a écrit :

ok, j'essay et j'te di
 :jap:  


 
il faut faire pareil pour ta structure adresse

n°301679
Clie
Posté le 05-02-2003 à 00:08:17  profilanswer
 

Poula j'ai rien dis, torché moi
Essaye ca :
cl = (struct client *)malloc(nb_elements * sizeof(struct client));

mood
Publicité
Posté le 05-02-2003 à 00:08:17  profilanswer
 

n°301690
Clie
Posté le 05-02-2003 à 00:10:06  profilanswer
 

Ok trois plomb de rtard, vais m'coucher moi  :sleep:

n°301693
vandekerpu​t
hooohhi'm'bohéé !!!!
Posté le 05-02-2003 à 00:12:25  profilanswer
 

désolé...mé ça marche po  :cry:

n°301695
fykman
Errare Humanum Est
Posté le 05-02-2003 à 00:12:57  profilanswer
 

Vandekerput a écrit :

désolé...mé ça marche po  :cry:  


 
il te dis quoi ?
 
donne le code complet


Message édité par fykman le 05-02-2003 à 00:13:32
n°301700
vandekerpu​t
hooohhi'm'bohéé !!!!
Posté le 05-02-2003 à 00:15:14  profilanswer
 


void enregistrer()
{
 int i = 0;
 
 while(cl[i].nom != "" )
 {i++;}
//cl = (struct client *)malloc(255 * sizeof(struct client));
 cl[i].nom = (char*)malloc(255);
 cl[i].adr.rue = (char*)malloc(255);
 cl[i].adr.ville = (char*)malloc(255);
 
 printf("ENREGISTREMENT D'UN CLIENT\n" );
 printf("Entrez le nom du client :" );
 scanf("%s",&cl[i].nom);
 printf("Entrez la rue du client :" );
 scanf("%s",&cl[i].adr.rue);
 printf("Entrez l'adresse du client :" );
 scanf("%s",&cl[i].adr.ville);
 printf("Entrez le Code Postal du client :" );
 scanf("%d",&cl[i].adr.cp);
 
}
 
c'est tout ce ki y'a, et il plante toujours au même endroit...

n°301713
vandekerpu​t
hooohhi'm'bohéé !!!!
Posté le 05-02-2003 à 00:20:08  profilanswer
 

pa grave, j'commence à m'endormir, en plus j'ai codé du PB toute la journée collée à l'écran du boulo...alor maintenant un supo et dodo!!!
merci kan même, à une prochaine fois peut-être
 :jap:   :hello:


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  pb!!!! unhandled exception..... : access violation

 

Sujets relatifs
[Access] j'arrive pas a transformer un stringC++ read-write access threadsafe
[BAT] lancer un compactage de base access[ACCESS] Filtrer données liste déroulante par rapport à une autre list
[Access] bizarrerie sur fonction Format[ASP] : viewer ACCESS
[access] champs texte dans un sous formulaire ?!?(VBA et Access) Empecher l'affichage d'une fenetre d'importation
Communication d'une exception entre une servlet et une appletBug avec VB liaison avec base access
Plus de sujets relatifs à : pb!!!! unhandled exception..... : access violation


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR