I'm currently making a program for a mud. It takes strings entered by the user and saves them in a file. Once that is finished it connects to the mud, and sends the strings out creating the character. I then plan on having an auto stat roller. However i've ran into a snag with this. Since each alignment of the mud gets a different set of races. I have to check it before I write it to the function. This is what I have so far. I'm wondering how I can create that into a table, and check against it. Also how to erase this ugly function and replace it with a more compact printf of the table itself. I'm a novice in code, and am self taught. I hope that explains why my code isn't exactly professional. :-P
So basically take a look, and give me an example of how to use printf and fprintf in conjunction with tables, and how to set up the table. Any help would be great.
This is the printf function I was speaking of.
This is part of the main function i'm using to write to the file.Code:// Prints the races for good alignment void do_good() { printf("------------------------------------------\n\r"); printf("human costs 0 experience points.\n\r"); printf("dwarf costs 500 experience points.\n\r"); printf("elf costs 500 experience points.\n\r"); printf("centaur costs 400 experience points.\n\r"); printf("gnome costs 400 experience points.\n\r"); printf("draconian costs 300 experience points.\n\r"); printf("changeling costs 300 experience points.\n\r"); printf("halfling costs 300 experience points.\n\r"); printf("minotaur costs 300 experience points.\n\r"); printf("arborian costs 500 experience points.\n\r"); printf("------------------------------------------\n\r"); }
Code:RACE: printf("What is your race to be?\n\r"); if (alignment == 'G') { do_good(); gets(race); // Now I need to check the race, which is a lot of || statements. // If it returns falsely I use goto to go back to the start of // the function. fprintf(outfile,race); //I'm assuming if it passes the if statements i can print it } else if (alignment == 'N') //then go through the same thing



LinkBack URL
About LinkBacks




I was simply stating my opinion.