Maze * getMaze (void) { /*Pointer to the maze file*/ FILE * mazeFile = openFile("maze.txt"); /*Convert the maze file to a 2D array*/ Maze * maze = convertMaze(mazeFile); convertBinary(maze); return maze; }
int main(int argc, char **argv) { std::string strIn, strOut, strBinName; struct stat fileStat; if (argc != 2) { printf("Usage:\n\t%s infile[.bin]\n", argv[0]); return 1; } strIn = argv[1]; if (strIn.substr(strIn.size() - 4, 4) != ".bin") { strOut = strIn + ".c"; strIn += ".bin"; } else strOut = strIn.substr(0, strIn.size() - 3) + "c"; strBinName = strOut.substr(0, strOut.size() - 2); inFd = open(strIn.c_str(), O_RDONLY | O_EXCL); if (inFd == -1 || stat(strIn.c_str(), &fileStat) != 0) { close(inFd); printf("Input file not found\n"); return 1; } fileSize = fileStat.st_size; outFd = open(strOut.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (outFd == -1) { close(inFd); printf("Could not open out file\n"); return 1; } convertBinary(strBinName.c_str()); close(inFd); return 0; }
int main() { int EV_current; int EV_count; int EV_total; struct EV_LameStruct * EV_digits; EV_digits = (struct EV_LameStruct*)malloc(sizeof(struct EV_LameStruct)); EV_count = 0; EV_digits->EV_one = 0; EV_digits->EV_two = 0; EV_digits->EV_three = 0; EV_digits->EV_four = 0; EV_digits->EV_five = 0; EV_digits->EV_six = 0; EV_digits->EV_seven = 0; EV_digits->EV_eight = 0; EV_digits->EV_nine = 0; scanf("%d", &EV_current); while ((EV_current!=0)) { if ((EV_current==1)) { EV_digits->EV_one = (EV_digits->EV_one+1); } else { if ((EV_current==2)) { EV_digits->EV_two = (EV_digits->EV_two+1); } else { if ((EV_current==3)) { EV_digits->EV_three = (EV_digits->EV_three+1); } else { if ((EV_current==4)) { EV_digits->EV_four = (EV_digits->EV_four+1); } else { if ((EV_current==5)) { EV_digits->EV_five = (EV_digits->EV_five+1); } else { if ((EV_current==6)) { EV_digits->EV_six = (EV_digits->EV_six+1); } else { if ((EV_current==7)) { EV_digits->EV_seven = (EV_digits->EV_seven+1); } else { if ((EV_current==8)) { EV_digits->EV_eight = (EV_digits->EV_eight+1); } else { EV_digits->EV_nine = (EV_digits->EV_nine+1); } } } } } } } } scanf("%d", &EV_current); } printf("%d\n",countTotal(EV_digits)); printRecursive(convertBinary(1), EV_digits->EV_one); printRecursive(convertBinary(2), EV_digits->EV_two); printRecursive(convertBinary(3), EV_digits->EV_three); printRecursive(convertBinary(4), EV_digits->EV_four); printRecursive(convertBinary(5), EV_digits->EV_five); printRecursive(convertBinary(6), EV_digits->EV_six); printRecursive(convertBinary(7), EV_digits->EV_seven); printRecursive(convertBinary(8), EV_digits->EV_eight); printRecursive(convertBinary(9), EV_digits->EV_nine); return 0; }