Vous n'êtes pas identifié.
Bon apparemment le passage par référence ( avec pointeur ) est aussi spécifique au c++, donc me revoila bien embêté:
J'ai un tableau texte[] de caracteres, et j'appelle une fonction writetext() qui va permettre a l'utilisateur d'écrire le contenu de ce tableau.
Seulement, comment je fais pour indiquer que c'est bien avec texte[] qu'il faut travailler et pas avec un autre tableau?
Hors ligne
En fait je n'arrive pas a compiler ca:
#include "casio2b.h"; // le tableau de char alpha n'a pas été remis ici int writetext(int x,int y,[color=red]unsigned char &texte[][/color],int n,int page,int couleur,int bg) { int i=0,j,key,type=0; //type: 0 lettres, 1 chiffres char c; while (texte[i]!=99) i++; do { j=1; key=getch(); if (key==28 || key==75 || key==72 || key==77 || key==80) j=0; if (type==0) if (j) if (!( (key<46||key>57) && (key<65||key>90) )) j=0; else if (j) if (!(key<48||key>57)) j=0; } while (j); if (key==28 || key==75 || key==72 || key==77 || key==80) return key; if (key!=83 && key!=56 && i!=n) { if (type==0) { c=key; if(key>=55 && key<=57) c+=22; if(key>=52 && key<=54) c+=28; if(key>=49 && key<=51) c+=36; if(key==48) c='Z'; if(key==46) c=' '; } else c=key-48; drawdchar(x+5*(i+1),y,c,page,couleur,bg); texte[i]=c; i++; } if (key==83 && i!=0) { i--; drawdchar(x+5*(i+1),y,' ',page,couleur,bg); texte[i]=99; } if (key==56) { type++; if (type==2) type=0; } return 0; } void drawdchar(int x,int y, char c1, int page,int coul,int bg) { char c2; int i,j; if (c1>=48 && c1<=57) c2=c1-48; if (c1>=65 && c1<=90) c2=c1-55; if (c1==' ') c2=36; if (c1=='<') c2=37; if (c1=='>') c2=38; if (c1=='[') c2=39; if (c1==']') c2=40; if (c1==':') c2=41; if (c1=='-') c2=42; if (c1=='?') c2=43; if (c1=='.') c2=44; if (c1=='$') c2=45; if (c1=='=') c2=46; if (c1=='(') c2=47; if (c1==')') c2=48; if (c1=='{') c2=49; if (c1=='}') c2=50; if (c1=='/') c2=51; if (c1=='\') c2=52; if (c1=='_') c2=53; if (c1=='!') c2=54; if (c1=='ø') c2=55; if (c1==',') c2=56; if (c1==';') c2=57; if (c1=='+') c2=58; if (c1=='*') c2=59; if (c1=='@') c2=60; if (c1=='`') c2=61; for(i=0;i<5;i++) for(j=0;j<4;j++) { if (alpha[c2][i][j]==1) setPix(x+j,y+i,page,coul); else if(bg!=-1) setPix(x+j,y+i,page,bg); } } void afftext(int x,int y,char st[],int page, int couleur,int bg ) { int l; for(l=0;st[l]!=' ';l++) drawdchar(x+5*l,y,st[l],page,couleur,bg);} void main() { int j; [color=red]unsigned char texte[10]="cccccccccc";[/color] clearpage(0); j=writetext(1,5,[color=red]texte[/color],10,0,1,-1); afftext(1,20,texte,0,1,-1); if (j==28) afftext(1,30,"exe",0,1,-1); if (j==75) afftext(1,30,"gauche",0,1,-1); if (j==77) afftext(1,30,"droite",0,1,-1); if (j==72) afftext(1,30,"haut",0,1,-1); if (j==80) afftext(1,30,"bas",0,1,-1); waitkey(); }
J'ai un probleme au niveau des pointeurs et du passage du tab texte[] vers la fonction writetext()...
Désolé de vous casser les pieds sans cesse, mais j'ai essayer pas mal de trucs sans aucun succès
Hors ligne
#include "casio2b.h"; // le tableau de char alpha n'a pas été remis ici int writetext(int x,int y,[color=red]unsigned char text[][/color],int n,int page,int couleur,int bg) { int i=0,j,key,type=0; //type: 0 lettres, 1 chiffres char c; while (text[i]!=99) i++; do { j=1; key=getch(); if (key==28 || key==75 || key==72 || key==77 || key==80) j=0; if (type==0) if (j) if (!( (key<46||key>57) && (key<65||key>90) )) j=0; else if (j) if (!(key<48||key>57)) j=0; } while (j); if (key==28 || key==75 || key==72 || key==77 || key==80) return key; if (key!=83 && key!=56 && i!=n) { if (type==0) { c=key; if(key>=55 && key<=57) c+=22; if(key>=52 && key<=54) c+=28; if(key>=49 && key<=51) c+=36; if(key==48 ) c='Z'; if(key==46) c=' '; } else c=key-48; drawdchar(x+5*(i+1),y,c,page,couleur,bg); text[i]=c; i++; } if (key==83 && i!=0) { i--; drawdchar(x+5*(i+1),y,' ',page,couleur,bg); text[i]=99; } if (key==56) { type++; if (type==2) type=0; } return 0; } void drawdchar(int x,int y, char c1, int page,int coul,int bg) { char c2; int i,j; if (c1>=48 && c1<=57) c2=c1-48; if (c1>=65 && c1<=90) c2=c1-55; if (c1==' ') c2=36; if (c1=='<') c2=37; if (c1=='>') c2=38; if (c1=='[') c2=39; if (c1==']') c2=40; if (c1==':') c2=41; if (c1=='-') c2=42; if (c1=='?') c2=43; if (c1=='.') c2=44; if (c1=='$') c2=45; if (c1=='=') c2=46; if (c1=='(') c2=47; if (c1==')') c2=48; if (c1=='{') c2=49; if (c1=='}') c2=50; if (c1=='/') c2=51; if (c1=='\') c2=52; if (c1=='_') c2=53; if (c1=='!') c2=54; if (c1=='ø') c2=55; if (c1==',') c2=56; if (c1==';') c2=57; if (c1=='+') c2=58; if (c1=='*') c2=59; if (c1=='@') c2=60; if (c1=='`') c2=61; for(i=0;i<5;i++) for(j=0;j<4;j++) { if (alpha[c2][i][j]==1) setPix(x+j,y+i,page,coul); else if(bg!=-1) setPix(x+j,y+i,page,bg); } } void afftext(int x,int y,char st[],int page, int couleur,int bg ) { int l; for(l=0;st[l]!=' ';l++) drawdchar(x+5*l,y,st[l],page,couleur,bg);} void main() { int j; [color=red]unsigned char texte[]="cccccccccc";[/color] clearpage(0); j=writetext(1,5,[color=red]texte[/color],10,0,1,-1); afftext(1,20,texte,0,1,-1); if (j==28 ) afftext(1,30,"exe",0,1,-1); if (j==75) afftext(1,30,"gauche",0,1,-1); if (j==77) afftext(1,30,"droite",0,1,-1); if (j==72) afftext(1,30,"haut",0,1,-1); if (j==80) afftext(1,30,"bas",0,1,-1); waitkey(); }
C soit &text, soit text[], ms po les 2 !!
voila, essaye maintenant ;-)
Hors ligne
Ben moi je veux bien mais ca ca va définir un tab texte[] et un tab text[] différents: donc les opérations sur text ne seront pas reproduites sur texte... si?
Hors ligne