// s Wang Li Xie Wu Li Huang Wang // f 4 4.1 3.7 5.2 4.1 3.7 1.5 3.0 // c a c p l c b d p m m o x int main(int argc, char ** argv) { FILE * f1 = fopen("inputdata.txt", "r"); FILE * f2 = fopen("outputdata.txt", "w"); char s[250]; assert(f1 && f2); while(fgets(s, 250, f1)) { // fprintf(stdout, "%d %s@%d %d\n", i, s, strlen(s), feof(f1)); // i++; char type, * t; type = * s; t = proccess(type, s + 2); fputs(t, f2); } // 这种判断文件结尾的方法会导致读取最后一行两次 // while (!feof(f1)) { // char type, * t; // fgets(s, 250, f1); // fprintf(stdout, "%s@%d %d\n", s, strlen(s), feof(f1)); // type = * s; // t = proccess(type, s + 2); // fputs(t, f2); // } fclose(f1); fclose(f2); return (EXIT_SUCCESS); }
bool one_step(){ char key = keyboard::get_char(); //Check if we are inputing data if (key != '\n'){ //Store it this->string_buffer[this->buff_index] = key; this->buff_index++; //Move characters and echo it. text_graphics::put_char(key, this->pos); this->pos++; text_graphics::set_cursor_pos(pos); } else{ //Go to the newline and set position + proccess command int cols = text_graphics::cols(); this->pos = (this->pos/cols)*cols + cols; //Clear and reset if we go to far. if (this->pos > 23*cols){ text_graphics::clear(); this->pos = 0; } text_graphics::set_cursor_pos(this->pos); if(proccess(this->string_buffer) == -1){ return false; }; } return true; }
int main(void) { int N = 0; scanf("%d", &N); /**!!**/ /**!!**/ getchar(); /**!!**/ /**!!**/ while(N--) proccess(); return 0; }