Okay, so I can get this to read the first line of a txt document. I just can't figure out how to get it to read the next lines. I have to use "user_input " in a function. The wait function just waits until the user hits enter. The text document has 11 lines of code. I know this is a total newb question, but I am baffled. The function gets called at the begining of the file.
HERE IS A PART OF MY CODE -SMALL PART:
Code:
int file_run(void){ char buffer[255]; ifstream command_input_file; command_input_file.open("p3test.txt", ios::in); command_input_file.getline(buffer, 255); if(command_input_file == NULL){ return 0;}; strcpy(user_input,buffer); wait(); return 0;
Code:
int parse_command_line(void) { if(COMMANDS_FROM_FILE == 1){ file_run();} if(COMMANDS_FROM_FILE ==0){ cout << "Enter the Commmand: \n"; cin.getline(user_input,' '); } // deliminates spaces and uses to separate tokens character_string = strtok(user_input," "); //compares the length of the string to allowable amount of characters. if( (strlen(user_input)) >= MAX_CMD_LINE_LENGTH){ cout << "Please Use " << MAX_CMD_LINE_LENGTH << " Characters or Less.\n"; return 0;} //cout << "Your Tokens Are: \n \n"; j = 0; //This continues to process each character in the string until it reaches the end. while(character_string != NULL) { //Analyzises each character in the string, one at a time. //character[j] = character_string; strcpy(cStrings[j],character_string); //error case if there are more than the 10 allowable tokens. if(j > (MAX_TOKENS_ON_A_LINE)-1){ cout << "Please Enter " << MAX_TOKENS_ON_A_LINE << " Tokens or Less.\n"; return 0; } //cout << character[j] << endl; j = j + 1; character_string = strtok(NULL, " "); } if
Comment