void readFile() { void testFseek(FILE *fp); FILE *fp; char ch,filename[20]; while(1) { printf("Please input a filename\n"); scanf("%s",filename); getchar();//ÎüÊջسµ if( (fp = fopen(filename,"r") )==NULL ) { printf("can't open file \"%s\" \n",filename); continue; } testFseek(fp); printf("\n======this is the start of the file.======\n"); while(!feof(fp)) { ch=fgetc(fp); putchar(ch); } printf("\n======this is the end of the file.======\n"); fclose(fp); if(!isContinue()) { return; } } }
void GenVideoT::run() { int t = static_cast<int>(1000*dt); int i = 0; while(true) { while (isPaused()) sleep(1); if (isStoped()) break; setTime(i * (t/1000.0)); emit nextImage(); waitSignal(); while (true) { QThread::msleep(t); if (isContinue()) break; if (isStoped()) goto END; } ++i; if (i == N) break; } END: mutex.lock(); isstop = false; mutex.unlock(); emit finishVideo(); }
void WECpiFeederThread::feedData2Cpi() { const boost::posix_time::seconds TIME_OUT(2); while(isContinue()) { mutex::scoped_lock aLock(fMsgQMutex); if(fMsgQueue.empty()) { boost::system_time const abs_time = boost::get_system_time()+ TIME_OUT; bool aTimedOut = fFeederCond.timed_wait(aLock, abs_time); if(!isContinue()) { aLock.unlock(); break; } // to handle spurious wake ups and timeout wake ups if((fMsgQueue.empty())||(!aTimedOut)) { aLock.unlock(); continue; } } messageqcpp::SBS aSbs = fMsgQueue.front(); fMsgQueue.pop(); aLock.unlock(); try { fOwner.pushData2Cpimport((*aSbs)); //cout << "Finished PUSHING data " << endl; } catch(runtime_error& e) { //cout << "Caught exception : " << e.what() << endl; //break; } aSbs.reset(); //forcefully clearing it // We start sending data request from here ONLY if(getQueueSize() == WEDataLoader::MAX_QSIZE) fOwner.sendDataRequest(); } cout << "CpiFeedThread Stopped!! " << endl; fStopped = true; }
TStr TGroup::OnScript(int Count) { TStr Result; bool fFirst = true; TGroupNode *p = GetNode(Count); while( isContinue(Count) ) { if( p->p_script != NULL ) p->p_script->OnScript(); if( p->next != NULL ) { ssi->SSIValue(p->ssiStream,OnScript(Count+1)); if( !query->eof() && p->AttrID.Length() > 0 ) p->ID = query->fieldByName(p->AttrID); } else { QueryToSSI(ssi,query); query->next(); } ssi->SSIBlock("¬First",!fFirst,false); fFirst = false; Result += ssi->SSIRes(p->ssiBlock); } return Result; }
void main() { char ch; while(1) { printf(" a.main_file();\n b.testLineStruct();\n"); printf(" c.sort_main();\n d.Common\n"); printf("--->"); while ((ch = getchar())=='\r'); flushall();//Çå¿ÕÊäÈ뻺³åÇø switch(ch) { case 'a': case 'A': main_file(); break; case 'b': case 'B': testLineStruct(); break; case 'C': case 'c': sort_main(); break; case 'D': case 'd': Common_main_test(); break; default: show_warn("ÊäÈëÓÐÎó~"); } if(!isContinue()) { system("pause"); exit(0); } } }
void modifyRecord() { int choice; char name[20]; // 指定的姓名 char num[15]; //指定的学号 int rank; //指定的排名 int index; // 指定记录的序号 do{ system("cls"); PRHEAD; printf(" 修改学生记录: \n\n\n"); printf(" 1. 按学号查询修改\n\n"); printf(" 2. 按姓名查询修改\n\n"); printf(" 3. 按名次查询修改\n\n"); printf(" 0. 返回主菜单\n\n"); choice = menu_select(0, 3); printf("\n"); switch(choice) { case 1: printf("请输入要查询的学号(Uxxxxxxxxx):"); scanf("%s", num); index = num_findRecord(num, 0); //查找 printf("\n"); if(index == -1) printf("没有找到相关学生记录!\n\n"); //找不到则给出提示 else { index_disPlay(index); printf("\n"); printf("确认修改记录(y/n)? "); printf("\n"); if( isContinue() ) { pmodify(&records[index-1]); } } break; case 2: printf("请输入姓名:"); scanf("%s", name); index = name_findRecord(name, 0); printf("\n"); if(index == -1) printf("没有找到相关记录!\n\n"); else { index_disPlay(index); printf("\n"); printf("确认修改记录(y/n)? "); printf("\n"); if( isContinue() ) { pmodify(&records[index-1]); } } break; case 3: printf("请输入名次:"); scanf("%d", &rank); index = rank_findRecord(rank, 0); printf("\n"); if(index == -1) printf("没有找到相关记录!\n"); else { index_disPlay(index); printf("\n"); printf("确认修改记录(y/n)? "); printf("\n"); if( isContinue() ) { pmodify(&records[index-1]); } } break; case 0: break; } printf("\n是否继续修改学生记录(y/n)?"); }while( isContinue() ); total_sortRecords(); }
/* 功 能:按要求查询指定学生信息 菜单函数 参 数:无 返 回 值:void 工作方式:可以按照学号、姓名或名次来查询。 */ void queryInfo() { do { system("cls"); // 清屏 int choice; //菜单选择参数 char name[20]; char num[15]; int rank; int index; PRHEAD; printf(" 查询学生记录\n\n\n"); printf(" 1. 按学号查询\n\n"); printf(" 2. 按姓名查询\n\n"); printf(" 3. 按名次查询\n\n"); printf(" 0. 返回主菜单\n\n"); choice = menu_select(0,3); printf("\n"); switch(choice) { case 1: printf("请输入学号:"); scanf("%s", num); //输入要查询的学号 index = num_findRecord(num, 0); printf("\n"); if(index == -1) // 若index为-1则表示没有找到指定的记录 printf("没有找到相关记录!\n"); else { showTable(); PR(index-1); //宏定义, 将查询到的信息打印出来 } break; case 2: printf("请输入姓名:"); scanf("%s", name); //输入要查询的姓名 index = name_findRecord(name, 0); printf("\n"); if(index == -1) printf("没有找到相关记录!\n"); else { showTable(); PR(index-1); //宏定义, 将查询到的信息打印出来 } break; case 3: printf("请输入名次:"); scanf("%d", &rank); // 输入要查询的名次 index = rank_findRecord(rank, 0); printf("\n"); if(index == -1) printf("没有找到相关记录!\n"); else { showTable(); PR(index-1); //宏定义, 将查询到的信息打印出来 } break; case 0: break; } printf("\n是否继续查询(y/n)? "); }while(isContinue()); }