This code works for like one iteration and then it quits working-I donno why.
Code:#include <iostream.h> #include <stdlib.h> #include <time.h> #include <ctype.h> int commandmain(); void funcroll6(void) { int roll6=0, num6roll=0, temproll; cout<<"Enter a number of 6-sided dice to roll:"; cin>>num6roll; while (num6roll>0) { temproll=(rand() % 6+1); roll6=temproll+roll6; num6roll = num6roll - 1; } cout<<"\nYou rolled for a total of "<<(roll6)<<"!"; } int main() { time_t seconds; time(&seconds); srand((unsigned int) seconds); while (commandmain()==0) commandmain(); return 0; } int commandmain() { char command[256], commain=0; cout<<"\nEnter a command:"; cin.getline(command, 256, '\n'); if(!strcmpi("dice", command)) { funcroll6(); } else if(!strcmpi("roll dice", command)) { funcroll6(); } else if(!strcmpi("roll them bones", command)) { funcroll6(); } else if(!strcmpi("help", command)) { cout<<"\nSince this is a dice program, try ''roll dice'' or ''dice'' or ''roll them bones''...And yes, the dragon is out sick."; } else if(!strcmpi("quit", command)) { commain=-1; } else { cout<<"\nEnter help for assistance:"; commain=0; } return (commain); }



LinkBack URL
About LinkBacks


