
jojomillenium
|
ALors en fait le probleme est vraiment bizzare, voici mon code, tu verra que a la fin de chaque boucle de mon while j'ecris dans un fichier la valeur du LLayer qui a ete sauvé... ca me donne dans le fichier exactement ce que je veux, c'est genial... mais a la fin de ma lecture du fichier quand tout es fini, je fait une boucle passant tous mes LLayer et en ecrivant danc chaque valeur lu dans un autre fichier pour verifier et la j'ai pas ce que je veux. Ci dessous mon code et le resultat de mes deux fichier, tu verra comme c'est bizarre!
void SetConfig(HWND hwndDlg) { char nom[100]; char* NomCharge;
char NomCharge2[100]; bool FoundConfig=false; int numlayer=-1; float h, r, g, b, p; SendMessage(GetDlgItem( hwndDlg , ID_SEL) , CB_GETLBTEXT, (WPARAM)SendMessage(GetDlgItem( hwndDlg , ID_SEL), CB_GETCURSEL, 0, 0), (LPARAM)nom);
CString test_nom;
test_nom = CString(nom); FILE *filein; char chaine[255]; filein = fopen("configs.3dconf", "rt"); // File To Load World Data From if(filein != NULL) { FoundConfig = false; while (fgets(chaine, 250, filein) != NULL) // On lit le fichier tant qu'on ne reçoit pas d'erreur (NULL) { if(FoundConfig==true) { //char* couchelu; sscanf(chaine, "%d %s; %f, %f, %f, %f, %f", &numlayer, couchelu, &h, &p, &r,&g,&b); switch(numlayer) { case 0: LLayer[numlayer].SetLayer(couchelu,"Well",0,-h,p,r,g,b,1.0); break; case 1: LLayer[numlayer].SetLayer(couchelu,"N Diff",0,-h,p,r,g,b,1.0); break; case 2: LLayer[numlayer].SetLayer(couchelu,"P Diff",0,-h,p,r,g,b,1.0); break; case 3: LLayer[numlayer].SetLayer(couchelu,"Poly 1",0,h,p,r,g,b,1.0); break; case 4: LLayer[numlayer].SetLayer(couchelu,"Poly 2",LLayer[3].zstart+LLayer[3].h,h,p,r,g,b,1.0); break; case 5: LLayer[numlayer].SetLayer(couchelu,"Cont",0,h,p,r,g,b,1.0); break; case 6: LLayer[numlayer].SetLayer(couchelu,"Metal 1",LLayer[5].zstart+LLayer[5].h,h,p,r,g,b,1.0); break; case 7: LLayer[numlayer].SetLayer(couchelu,"Via 1",LLayer[6].zstart+LLayer[6].h,h,p,r,g,b,1.0); break; case 8: LLayer[numlayer].SetLayer(couchelu,"Metal 2",LLayer[7].zstart+LLayer[7].h,h,p,r,g,b,1.0); break; case 9: LLayer[numlayer].SetLayer(couchelu,"Via 2",LLayer[8].zstart+LLayer[8].h,h,p,r,g,b,1.0); break; case 10: LLayer[numlayer].SetLayer(couchelu,"Metal 3",LLayer[9].zstart+LLayer[9].h,h,p,r,g,b,1.0); break; case 11: LLayer[numlayer].SetLayer(couchelu,"NPLUS",0,h,p,r,g,b,1.0); break; case 12: LLayer[numlayer].SetLayer(couchelu,"PPLUS",0,h,p,r,g,b,1.0); break; case 13: LLayer[4].zstart=LLayer[4].zstart+h; break; } }
if(CString(3,chaine)=="nom") { sscanf(chaine, "nom %s", &nom); if(CString(nom).CompareNoCase(test_nom)) { FoundConfig = true; NomCharge = nom; } else FoundConfig = false; } if(numlayer!=-1) { FILE *stream; stream=fopen("tes0.3dconf","a+"); fprintf(stream,"nom %s %s\n",LLayer[numlayer].nom_cif, LLayer[numlayer].nom_couche); fclose(stream); numlayer=-1; } } } sprintf (NomCharge2, "Config %s chargé avec succès ", NomCharge); SendMessage(hStatusBar, SB_SETTEXT, 0, (LONG)NomCharge2); ConfigLoaded = true;
FILE *stream; stream=fopen("tes.3dconf","w"); for(int t=0; t<12; t++) { fprintf(stream,"nom %s %s\n",LLayer[t].nom_cif, LLayer[t].nom_couche); } fclose(stream); }
Fichier que je veux obtenir et que j'obtiens dans tes0.3dconf
nom NWELL; Well nom ACTIVE; N Diff nom ACTIVE; P Diff nom POLY; Poly 1 nom CONT; Cont nom METAL1; Metal 1 nom VIA1; Via 1 nom METAL2; Metal 2 nom PPLUS; PPLUS
Fichier que j'obiten dans tes.3dconf ... donc bizzarement remodifier par je ne sais pas quoi!
nom PPLUS; Well nom PPLUS; N Diff nom PPLUS; P Diff nom PPLUS; Poly 1 nom ; ; nom PPLUS; Cont nom PPLUS; Metal 1 nom PPLUS; Via 1 nom PPLUS; Metal 2 nom ; ; nom ; ; nom ; ;
|