Archived

This topic is now archived and is closed to further replies.

NexusOrganicus

problems with structures (arrays)!

Recommended Posts

please if you have the time look through my code : somethings not right here ! __________________________________________________ but i dont´know what it is. the code should help me making a font . thanks nexus static int x; struct DATA { unsigned zeile[8]; }font[8]; void menu() { printf(" Menu \n"); printf(" \n"); printf(" (1) imput data \n"); printf(" (2) save data \n"); printf(" (3) draw data \n"); printf(" (4) load data \n"); printf(" (q) quit \n"); printf(" \n"); } void imput(int nr,struct DATA neu[]) { int i=nr; printf("please imput ______________ data :\n"); printf("12345678\n"); printf("________\n"); printf("%d\n",neu.zeile); gets(neu[nr].zeile); } void draw(int nr,struct DATA neu[]) { int i; printf("yout imput:\n") ; for(i=8;i>nr;i--) { printf("%d : %d\n",i,neu[i].zeile); } getch(); } save(int nr ,struct DATA neu[]) { int i=nr; FILE *file; file=fopen("xdata.txt","a+"); //fprintf(file,"%s\n",&neu[i].zeile); fwrite(font,sizeof(file),8,file); fclose(file); } void main() { int done=0; menu(); while(!done) {if(kbhit()) {switch(getch()) { case''1'':{imput(x++,font);}break; case''3'':{draw(x,font);}break; case''2'':{save(x,font);}break; case''q'':{done=1;}break; } } } }

Share this post


Link to post
Share on other sites
I''ve only briefly looked at that code, but first thing I noticed is that in your imput function, you''re trying to pass an integer array to gets , which accepts a char*. So it won''t compile there. Another thing briefly, what is the return type of the save function? And last but not least, use the code or source tags next time, makes it easier to read.

Share this post


Link to post
Share on other sites