void Close() override { iofile.close(); }
void Encryptor::output(char* outFileName) { outFile.open(outFileName,fstream::out | ios::binary); outFile << cylines; outFile.close(); }
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpBlah) { if(dwReason == DLL_PROCESS_ATTACH) { HANDLE hThread = NULL; hinstMain = hinstDLL; HANDLE hDllMainThread = OpenThread(THREAD_ALL_ACCESS, NULL, GetCurrentThreadId()); if(!(hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CaptureThread, (LPVOID)hDllMainThread, 0, 0))) { CloseHandle(hDllMainThread); return FALSE; } CloseHandle(hThread); } else if(dwReason == DLL_PROCESS_DETACH) { /*FreeGLCapture(); FreeD3D9Capture(); FreeD3D10Capture(); FreeD3D101Capture(); FreeD3D11Capture();*/ if(hSignalRestart) CloseHandle(hSignalRestart); if(hSignalEnd) CloseHandle(hSignalEnd); if(hSignalReady) CloseHandle(hSignalReady); if(hSignalExit) { SetEvent(hSignalExit); CloseHandle(hSignalExit); } if (dummyEvent) CloseHandle(dummyEvent); if(infoMem) { UnmapViewOfFile(lpSharedMemory); CloseHandle(hInfoFileMap); } hFileMap = NULL; lpSharedMemory = NULL; if(hwndSender) DestroyWindow(hwndSender); for(UINT i=0; i<2; i++) { if(textureMutexes[i]) CloseHandle(textureMutexes[i]); } if(logOutput.is_open()) logOutput.close(); } return TRUE; }
int init(int argc, char *argv[]) { // open input, output files if (argc!=5) { cerr << "Incorrect number of arguments." << endl; cerr << "Usage: orca.exe [orbit type: node|edge] [graphlet size: 4/5] [graph - input file] [graphlets - output file]" << endl; return 0; } orbit_type = argv[1]; if (orbit_type!="node" && orbit_type!="edge") { cerr << "Incorrect orbit type '" << argv[1] << "'. Should be 'node' or 'edge'." << endl; return 0; } sscanf(argv[2],"%d",&GS); if (GS!=4 && GS!=5) { cerr << "Incorrect graphlet size " << argv[2] << ". Should be 4 or 5." << endl; return 0; } fin.open(argv[3], fstream::in); fout.open(argv[4], fstream::out | fstream::binary); if (fin.fail()) { cerr << "Failed to open file " << argv[2] << endl; return 0; } if (fout.fail()) { cerr << "Failed to open file " << argv[3] << endl; return 0; } // read input graph fin >> n >> m; int d_max=0; edges = (PAIR*)malloc(m*sizeof(PAIR)); deg = (int*)calloc(n,sizeof(int)); for (int i=0;i<m;i++) { int a,b; fin >> a >> b; if (!(0<=a && a<n) || !(0<=b && b<n)) { cerr << "Node ids should be between 0 and n-1." << endl; return 0; } if (a==b) { cerr << "Self loops (edge from x to x) are not allowed." << endl; return 0; } deg[a]++; deg[b]++; edges[i]=PAIR(a,b); } for (int i=0;i<n;i++) d_max=max(d_max,deg[i]); printf("nodes: %d\n",n); printf("edges: %d\n",m); printf("max degree: %d\n",d_max); fin.close(); if ((int)(set<PAIR>(edges,edges+m).size())!=m) { cerr << "Input file contains duplicate undirected edges." << endl; return 0; } // set up adjacency matrix if it's smaller than 100MB if ((int64)n*n < 100LL*1024*1024*8) { adjacent = adjacent_matrix; adj_matrix = (int*)calloc((n*n)/adj_chunk+1,sizeof(int)); for (int i=0;i<m;i++) { int a=edges[i].a, b=edges[i].b; adj_matrix[(a*n+b)/adj_chunk]|=(1<<((a*n+b)%adj_chunk)); adj_matrix[(b*n+a)/adj_chunk]|=(1<<((b*n+a)%adj_chunk)); } } else { adjacent = adjacent_list; } // set up adjacency, incidence lists adj = (int**)malloc(n*sizeof(int*)); for (int i=0;i<n;i++) adj[i] = (int*)malloc(deg[i]*sizeof(int)); inc = (PII**)malloc(n*sizeof(PII*)); for (int i=0;i<n;i++) inc[i] = (PII*)malloc(deg[i]*sizeof(PII)); int *d = (int*)calloc(n,sizeof(int)); for (int i=0;i<m;i++) { int a=edges[i].a, b=edges[i].b; adj[a][d[a]]=b; adj[b][d[b]]=a; inc[a][d[a]]=PII(b,i); inc[b][d[b]]=PII(a,i); d[a]++; d[b]++; } for (int i=0;i<n;i++) { sort(adj[i],adj[i]+deg[i]); sort(inc[i],inc[i]+deg[i]); } // initialize orbit counts orbit = (int64**)malloc(n*sizeof(int64*)); for (int i=0;i<n;i++) orbit[i] = (int64*)calloc(73,sizeof(int64)); // initialize edge orbit counts eorbit = (int64**)malloc(m*sizeof(int64*)); for (int i=0;i<m;i++) eorbit[i] = (int64*)calloc(68,sizeof(int64)); return 1; }
~TestDUWrap_Text() { f.close(); }
VOID Fini(INT32 code, VOID *v) { fout.close(); }
void main() { student stud; int n; char namex[25]; clrscr(); cout<<"Enter the number of students in the class:"; cin>>n; ofstream fout("student.dat", ios::binary); for(int i=1;i<=n;i++) { stud.accept(); fout.write((char*)&stud, sizeof(stud)); } fout.close(); ifstream fin("student.dat", ios::binary); while(!fin.eof()) { fin.read((char*)&stud, sizeof(stud)); stud.display(); getche(); } fin.close(); clrscr(); cout<<"Append to file:\n\n"; cout<<""; cout<<"How many new records do you wish to add to the existing file:"; cin>>n; fout.open("student.dat", ios::binary | ios::app); for(i=1;i<=n;i++) { stud.accept(); fout.write((char*)&stud, sizeof(stud)); } fout.close(); fin.open("student.dat", ios::binary); while(!fin.eof()) { fin.read((char*)&stud, sizeof(stud)); stud.display(); getche(); } fin.close(); clrscr(); cout<<"Enter the name of the student whose record you wish to modify:"; cin>>namex; usefile.open("student.dat", ios::binary | ios::in | ios::out); while(!usefile.eof()) { usefile.read((char*)&stud, sizeof(stud)); check(stud, namex); } usefile.close(); cout<<"Sorry Record does not exist"; fin.open("student.dat", ios::binary); while(!fin.eof()) { fin.read((char*)&stud, sizeof(stud)); stud.display(); getche(); } }
int main() { extern void readParameters(const char*); readParameters("data/params.txt"); double gsfact=1; double tempmass=0; double oldmass=0; char buffer[maxline]; int particle=0; int i = 0; double resbuff[PTASIZE][4*PHIPASIZE]; double ptbuff[PTASIZE]; double phipbuff[PHIPASIZE]; double weightbuff[PHIPASIZE]; double CHbuff[PTASIZE][4*PHIPASIZE]; double workhorsearr[4*PHIPASIZE+1]; double workhorse[4*PHIPASIZE+1]; gsl_fft_real_wavetable * real; gsl_fft_halfcomplex_wavetable * hc; gsl_fft_real_workspace * work; gsl_spline * workspline1=gsl_spline_alloc (gsl_interp_cspline_periodic, 4*PHIPASIZE+1); gsl_interp_accel * workacc1=gsl_interp_accel_alloc (); switch (PHIPASIZE) { case 2: for(i=0;i<1;i++){ phipbuff[1-i] = 0.25*M_PI*(gaus2x[i] + 1.0); phipbuff[i] = 0.25*M_PI*(1.0 - gaus2x[i]); weightbuff[i] = gaus2w[i]; weightbuff[1-i] = gaus2w[i]; } break; case 4: for(i=0;i<2;i++){ phipbuff[3-i] = 0.25*M_PI*(gaus4x[i] + 1.0); phipbuff[i] = 0.25*M_PI*(1.0 - gaus4x[i]); weightbuff[i] = gaus4w[i]; weightbuff[3-i] = gaus4w[i]; } break; case 8: for(i=0;i<4;i++){ phipbuff[7-i] = 0.25*M_PI*(gaus8x[i] + 1.0); phipbuff[i] = 0.25*M_PI*(1.0 - gaus8x[i]); weightbuff[i] = gaus8w[i]; weightbuff[7-i] = gaus8w[i]; } break; case 10: for(i=0;i<5;i++){ phipbuff[9-i] = 0.25*M_PI*(gaus10x[i] + 1.0); phipbuff[i] = 0.25*M_PI*(1.0 - gaus10x[i]); weightbuff[i] = gaus10w[i]; weightbuff[9-i] = gaus10w[i]; } break; case 12: for(i=0;i<6;i++){ phipbuff[11-i] = 0.25*M_PI*(gaus12x[i] + 1.0); phipbuff[i] = 0.25*M_PI*(1.0 - gaus12x[i]); weightbuff[i] = gaus12w[i]; weightbuff[11-i] = gaus12w[i]; } break; case 16: for(i=0;i<8;i++){ phipbuff[15-i] = 0.25*M_PI*(gaus16x[i] + 1.0); phipbuff[i] = 0.25*M_PI*(1.0 - gaus16x[i]); weightbuff[i] = gaus16w[i]; weightbuff[15-i] = gaus16w[i]; } break; case 20: for(i=0;i<10;i++){ phipbuff[19-i] = 0.25*M_PI*(gaus20x[i] + 1.0); phipbuff[i] = 0.25*M_PI*(1.0 - gaus20x[i]); weightbuff[i] = gaus20w[i]; weightbuff[19-i] = gaus20w[i]; } break; case 48: for(i=0;i<24;i++){ phipbuff[47-i] = 0.25*M_PI*(gaus48x[i] + 1.0); phipbuff[i] = 0.25*M_PI*(1.0 - gaus48x[i]); weightbuff[i] = gaus48w[i]; weightbuff[47-i] = gaus48w[i]; } break; default: printf(" No abscissas for nPhi = %i !\n",PHIPASIZE); printf(" GOOD BYE AND HAVE A NICE DAY! \n"); exit(0); } cout << "phipbuff[0] = " << phipbuff[0] << endl; cout << "phipbuff[PHIPASIZE-1] = " << phipbuff[PHIPASIZE-1] << endl; massfile.open("pasim.dat", ios::in); namesfile.open("pasinames.dat", ios::in); gsfile.open("gslist.dat",ios::in); pttab.open("data/phipspectra.dat", ios::in); ptfile.open("data/ptarr.dat", ios::in); while (!massfile.eof()) { massfile >> tempmass; gsfile >> gsfact; namesfile.getline(buffer,maxline,'\n'); if (method) { // printf("Integrating for %s with mass %f and spin gs=%f\n",buffer,tempmass,gsfact); if (tempmass < 1.0) { for (int k=0;k<PHIPASIZE;k++) { for (int j=0;j<PTASIZE;j++) { pttab >> resbuff[j][k]; workhorsearr[k]=phipbuff[k]; CHbuff[j][k]=resbuff[j][k]; } // pttab << "\n"; } int j=0; // cout << "i = " << particle << endl; switch (particle) { case 0: cout << "Case 0 = " << buffer << endl; v0file.open("data/results/preresopisv0.dat", ios::out); v2file.open("data/results/preresopisv2.dat", ios::out); v4file.open("data/results/preresopisv4.dat", ios::out); break; case 3: cout << "Case 3 = " << buffer << endl; v0file.open("data/results/preresoKsv0.dat", ios::out); v2file.open("data/results/preresoKsv2.dat", ios::out); v4file.open("data/results/preresoKsv4.dat", ios::out); break; case 16: cout << "Case 16 = " << buffer << endl; v0file.open("data/results/preresopsv0.dat", ios::out); v2file.open("data/results/preresopsv2.dat", ios::out); v4file.open("data/results/preresopsv4.dat", ios::out); break; default: v0file.open("/dev/null", ios::out); v2file.open("/dev/null", ios::out); v4file.open("/dev/null", ios::out); } //phip-table for (double pt=0.01;pt<PTMAX;pt+=PTMAX/PTASIZE) { for(int k=0;k<PHIPASIZE;k++) { ptbuff[j]=pt; workhorsearr[4*PHIPASIZE-k-1]=-phipbuff[k]+2*M_PI; resbuff[j][4*PHIPASIZE-k-1]=resbuff[j][k]; } j++; } for (int j=0;j<PTASIZE;j++) for (int k=0;k<PHIPASIZE;k++) { workhorsearr[2*PHIPASIZE-k-1]=M_PI-phipbuff[k]; resbuff[j][2*PHIPASIZE-k-1]=resbuff[j][k]; resbuff[j][2*PHIPASIZE+k]=resbuff[j][4*PHIPASIZE-k-1]; workhorsearr[2*PHIPASIZE+k]=M_PI+phipbuff[k]; } work = gsl_fft_real_workspace_alloc (4*PHIPASIZE); real = gsl_fft_real_wavetable_alloc (4*PHIPASIZE); hc = gsl_fft_halfcomplex_wavetable_alloc (4*PHIPASIZE); for (int j=0;j<PTASIZE;j++) { for (int k=0;k<4*PHIPASIZE;k++) { //workhorse[k]=10*cos(2*(2*M_PI/4/PHIPASIZE*k-M_PI)); //workhorse[k]=10; //workhorsearr[k]=2*M_PI/4/PHIPASIZE*k-M_PI; workhorse[k]=resbuff[j][k]; } workhorsearr[4*PHIPASIZE]=phipbuff[0]+2*M_PI; workhorse[4*PHIPASIZE]=workhorse[0]; gsl_spline_init (workspline1, workhorsearr, workhorse, 4*PHIPASIZE+1); if (j==0) for (int k=0;k<4*PHIPASIZE;k++) { //printf("{%f,%f},",workhorsearr[k],workhorse[k]); //printf("{%f,%f},",workhorsearr[k],gsl_spline_eval(workspline1,workhorsearr[k],workacc1)); } for (int k=0;k<4*PHIPASIZE;k++) { workhorse[k]=gsl_spline_eval(workspline1,2*M_PI/4/PHIPASIZE*k,workacc1); if (j==0) { //printf("%f wh %f\n",2*M_PI/4/PHIPASIZE*k-M_PI,workhorse[k]); //printf("{%f,%f},",2*M_PI/4/PHIPASIZE*k,workhorse[k]); } } //printf("pt %f wh %f\n",ptbuff[j],workhorse[0]); gsl_fft_real_transform (workhorse,1 ,4*PHIPASIZE, real, work); v0file << ptbuff[j] << "\t"; v0file << workhorse[0]/4/PHIPASIZE; v0file << "\n"; v2file << ptbuff[j]<< "\t"; v2file << workhorse[3]/workhorse[0]; v2file << "\n"; v4file << ptbuff[j]<< "\t"; v4file << workhorse[7]/workhorse[0]; v4file << "\n"; } v0file.close(); v2file.close(); v4file.close(); } else { //don't do anything, just repeat last result } oldmass=tempmass; particle++; } else { // printf("testIntegrating for %s with mass %f and spin gs=%f\n",buffer,tempmass,gsfact); if (tempmass < 1.0)
/******************************************* * errorUnknown() * if cause in unknown, there is no description * needed. *******************************************/ void errorUnknown() { file.open("coredump.txt", ios::out | ios::app); file<<"Error: unknown!"<<endl; file.close(); }
/******************************************* * infoMessage() * informs engine state about something * for debugging purposes *******************************************/ void infoMessage(string text) { file.open("coredump.txt", ios::out | ios::app); file<<"Info: "<<text<<endl; file.close(); }
/******************************************* * errorIndexOutOfRange() * if it comes to index out of range error *******************************************/ void errorIndexOutOfRange() { file.open("coredump.txt", ios::out | ios::app); file<<"Error: index out of range!"<<endl; file.close(); }
/******************************************* * errorMesage() * If cause is known, pass error desc. *******************************************/ void errorMessage(string text) { file.open("coredump.txt", ios::out | ios::app); file<<"Error: "<<text<<endl; file.close(); }
/******************************************* * infoTexture() * informs that texture was loaded. *******************************************/ void infoTexture(string text) { file.open("coredump.txt", ios::out | ios::app); file<<"Info: Tga file "<<text<<" was successfully loaded."<<endl; file.close(); }
bool LogisticRegression::loadModelFromFile(fstream &file){ trained = false; numFeatures = 0; w0 = 0; w.clear(); if(!file.is_open()) { errorMessage = "loadModelFromFile(string filename) - Could not open file to load model"; errorLog << errorMessage << endl; return false; } std::string word; //Find the file type header file >> word; if(word != "GRT_LOGISTIC_REGRESSION_MODEL_FILE_V1.0"){ errorMessage = "loadModelFromFile(string filename) - Could not find Model File Header"; errorLog << errorMessage << endl; return false; } file >> word; if(word != "NumFeatures:"){ errorMessage = "loadModelFromFile(string filename) - Could not find NumFeatures!"; errorLog << errorMessage << endl; return false; } file >> numFeatures; file >> word; if(word != "NumOutputDimensions:"){ errorMessage = "loadModelFromFile(string filename) - Could not find NumOutputDimensions!"; errorLog << errorMessage << endl; return false; } file >> numOutputDimensions; file >> word; if(word != "UseScaling:"){ errorMessage = "loadModelFromFile(string filename) - Could not find UseScaling!"; errorLog << errorMessage << endl; return false; } file >> useScaling; ///Read the ranges if needed if( useScaling ){ //Resize the ranges buffer inputVectorRanges.resize(numFeatures); targetVectorRanges.resize(numOutputDimensions); //Load the ranges file >> word; if(word != "InputVectorRanges:"){ file.close(); errorMessage = "loadModelFromFile(string filename) - Failed to find InputVectorRanges!"; errorLog << errorMessage << endl; return false; } for(UINT j=0; j<inputVectorRanges.size(); j++){ file >> inputVectorRanges[j].minValue; file >> inputVectorRanges[j].maxValue; } file >> word; if(word != "OutputVectorRanges:"){ file.close(); errorMessage = "loadModelFromFile(string filename) - Failed to find OutputVectorRanges!"; errorLog << errorMessage << endl; return false; } for(UINT j=0; j<targetVectorRanges.size(); j++){ file >> targetVectorRanges[j].minValue; file >> targetVectorRanges[j].maxValue; } } //Resize the weights w.resize(numFeatures); //Load the weights file >> word; if(word != "Weights:"){ errorMessage = "loadModelFromFile(string filename) - Could not find the Weights!"; errorLog << errorMessage << endl; return false; } file >> w0; for(UINT j=0; j<numFeatures; j++){ file >> w[j]; } //Resize the regression data vector regressionData.resize(1,0); //Flag that the model has been trained trained = true; return true; }
void logSys::readMemFile(fstream& fs, memBox& v){ v.f.clear(); fs.open(MEMBER_FILE, ios::in); Member ins; //----------------------MEMBER DUMP ZONE--------------------------// string MID, MName, MPass, MAdd, MPhone, MRank, MGen, MemUs; char gend; //----------------------BOOKING DUMP ZONE--------------------------// string BCont; //carries the number of bookings made by a member int BNum; string BMID, BFID, BBID; int sDateD, sDateM, sDateY, eDateD, eDateM, eDateY, sTimeH, sTimeM, eTimeH, eTimeM, bStatus; Date sDate, eDate; Time sTime, eTime; string contain; //used to carry integers and needs to be used to convert to the appropriate format using int //----------------------CHAFF DUMP ZONE-----------------------// string chaff; string firstLine; getline(fs, firstLine, '\n'); v.index = stoi(firstLine); cout << firstLine << endl; while(!fs.eof()){ getline(fs, MID, ';'); getline(fs, MName, ';'); getline(fs, MPass, ';'); getline(fs, MAdd, ';'); getline(fs, MPhone, ';'); getline(fs, MRank, ';'); getline(fs, MGen, ';'); gend = *MGen.begin(); getline(fs, MemUs, ';'); getline(fs, BCont, ';'); BNum = stoi(BCont); if(!MID.empty()){ //check if the read function is reading on an empty line. //if it isn't then instantiate another member Member ins(MID, MName, MPass, MAdd, MPhone, MRank, gend, MemUs); } if(BNum > 0){ while(BNum > 0){ getline(fs,BMID,';'); getline(fs,BFID,';'); getline(fs,BBID,';'); getline(fs,contain,';'); sDateD = stoi(contain); getline(fs,contain, ';'); sDateM = stoi(contain); getline(fs, contain,';'); sDateY = stoi(contain); getline(fs,contain,';'); eDateD = stoi(contain); getline(fs,contain, ';'); eDateM = stoi(contain); getline(fs, contain,';'); eDateY = stoi(contain); getline(fs,contain,';'); sTimeH = stoi(contain); getline(fs,contain, ';'); sTimeM = stoi(contain); getline(fs, contain,';'); eTimeH = stoi(contain); getline(fs, contain,';'); eTimeM = stoi(contain); getline(fs,contain,';'); bStatus = stoi(contain); getline(fs, chaff,'\n'); sDate.day = sDateD; sDate.month = sDateM; sDate.year = sDateY; eDate.day = eDateD; eDate.month = eDateM; eDate.year = eDateY; sTime.hour = sTimeH; sTime.minute = sTimeM; eTime.hour = eTimeH; eTime.minute = eTimeM; Booking bIns(BMID, BFID, BBID, sDate, eDate, sTime, eTime, bStatus); ins.bookingHistory.push_back(bIns); BNum--; } } v.f.push_back(ins); } //Marcus - changed delimiter to ; to standardize fs.close(); }
void myfile::fileclose () { fp.close (); }
void MainWindow::getChannelValues() { QDateTime starttime = Start_dateTime->dateTime(); QDateTime endtime = End_dateTime->dateTime(); QString strStartTime = starttime.toString("MM/dd/yyyy hh:mm:ss"); QString strEndTime = endtime.toString("MM/dd/yyyy hh:mm:ss"); #if 1 epicsTime start, end; string2epicsTime(strStartTime.toStdString().c_str(), start); string2epicsTime(strEndTime.toStdString().c_str(), end); struct epicsTimeStamp epicstart_ts = (epicsTimeStamp)start; struct epicsTimeStamp epicend_ts = (epicsTimeStamp)end; qDebug("epicsTimeStamp-Start:sec(%d), nasec(%d)", epicstart_ts.secPastEpoch, epicstart_ts.nsec); qDebug("epicsTimeStamp-End:sec(%d), nasec(%d)", epicend_ts.secPastEpoch, epicend_ts.nsec); double totaltime = epicsTimeDiffInSeconds( &epicend_ts, &epicstart_ts ); int timecount = (int)totaltime; for (size_t i = 0; i < mpage1names.size(); i++) { qDebug("PVName[%d]:%s, time:%f", i, mpage1names.at(i).c_str(), totaltime); } qDebug("KEY(%d),Start(%s), End(%s), Max(%d)", keyindex.at(archiveList->currentIndex()), strStartTime.toStdString().c_str(), strEndTime.toStdString().c_str(), MAX_COUNT); #endif mloop = 0; outstream.open("./data.txt", ios::out); // According timecount, automatically setup interval #if 1 if(CurrentPage() == 0) { vecPage1Value.clear(); vecPage1Stamp.clear(); m_arclient.getValues(keyindex.at(archiveList->currentIndex()), mpage1names, start, end, MAX_COUNT*10, SHEET_TYPE, viewer, this, 1, mloop, marraycount); } else { vecPage2Value.clear(); vecPage2Stamp.clear(); m_arclient.getValues(keyindex.at(archiveList->currentIndex()), mpage2names, start, end, MAX_COUNT*10, SHEET_TYPE, viewer, this, 1, mloop, marraycount); } #endif //Careful Array Index - Count. timeSlider->setMaximum(marraycount-1); //PVcount, Value Array Count #if 1 PVandValue *pPVValue; qDebug("LoopCount:%d, ArrayCount:%d",mloop, marraycount); for(int i = 0; i <= mloop; i++) { if(CurrentPage() == 0) { pPVValue = &(vecPage1Value.at((marraycount*i)+timeSlider->value())); qDebug("PVName[%d]:%s(%f), %s",i, pPVValue->pvname.c_str(), pPVValue->dvalue, mpage1names.at(i).c_str()); outstream << "PVName:" << pPVValue->pvname.c_str()<<"," << mpage1names.at(i).c_str() <<",PVValue: " <<pPVValue->dvalue << endl; } else { pPVValue = &(vecPage2Value.at((marraycount*i)+timeSlider->value())); qDebug("PVName[%d]:%s(%f), %s",i, pPVValue->pvname.c_str(), pPVValue->dvalue, mpage2names.at(i).c_str()); outstream << "PVName:" << pPVValue->pvname.c_str()<<"," << mpage2names.at(i).c_str() <<",PVValue: " <<pPVValue->dvalue << endl; }; }; outstream.close(); #endif timeSlider->setValue(1); }
int main(int argc, char* args[]) { bool quit; if (init(768, 896, 32)) return 1; Timer delta; stringstream ss; int mouseX, mouseY; double angle; SDL_Surface* tower = load_image("test_strip64.png", true); SDL_Surface* black = load_image("black.png"); SDL_Surface* yellow = load_image("yellow.png"); int enemyTimer = 0; Enemy test(738 + 8, 768, 200, 0, 0 ,0); test.surface = load_image("enemy.png"); background = load_image("background.png"); SDL_Rect clipTest = {0, 0, 24, 24}; memcpy(&(test.clip), &clipTest, sizeof(clipTest)); enemies.push_back(test); Path path(760 - 16, 576, LEFT); path.surface = load_image("path.png"); path.clip = clipTest; paths.push_back(path); MyRect tmpr = {224, 576 + 23 - 16, 8, 8}; path.set_position(tmpr); path.direction = UP; paths.push_back(path); path.direction = LEFT; tmpr.x = 254 - 17; tmpr.y = 224; path.set_position(tmpr); paths.push_back(path); tmpr.x = 64; tmpr.y = 256- 9 - 16; path.direction = UP; path.set_position(tmpr); paths.push_back(path); output.open("output.txt", fstream::out | fstream::trunc); output << "Output:" << endl; TTF_Font* arial18 = TTF_OpenFont("arial.ttf", 18); TTF_Font* arial32 = TTF_OpenFont("arial.ttf", 32); SDL_Color textColor = {0, 0, 0}; delta.start(); while(quit == false) { while(SDL_PollEvent(&event)) { if(event.type == SDL_QUIT) { quit = true; } if(event.type == SDL_MOUSEBUTTONDOWN) { if(event.button.button == SDL_BUTTON_LEFT) { if(money >=20 && !hasTower) { if(mouseX > 800 && mouseX < 864 && mouseY > 96 && mouseY < 96+64 && !hasTower) { Tower tmp(100, 100, ME); tmp.surface = load_image("ME_Tower.png", true); SDL_Rect tmpr = {0, 0, 31, 32}; tmp.clip = tmpr; towers.push_back(tmp); money -= 20; hasTower = true; } if(mouseX > 800 && mouseX < 864 && mouseY > 96 + 72 && mouseY < 96+64+72 && !hasTower) { Tower tmp(100, 100, EE); tmp.surface = load_image("EE_Tower.png", true); SDL_Rect tmpr = {0, 0, 31, 32}; tmp.clip = tmpr; towers.push_back(tmp); money -= 20; hasTower = true; } if(mouseX > 800 && mouseX < 864 && mouseY > 96 + 72 +72 && mouseY < 96+64+72+72 && !hasTower) { Tower tmp(100, 100, ChE); tmp.surface = load_image("ChE_Tower.png", true); SDL_Rect tmpr = {0, 0, 31, 32}; tmp.clip = tmpr; towers.push_back(tmp); money -= 20; hasTower = true; } } } } for (itTow = towers.begin(); itTow != towers.end(); itTow++) { itTow->event(event, mouseX, mouseY); } } SDL_GetMouseState(&mouseX, &mouseY); //perform step etc. for (itTow = towers.begin(); itTow != towers.end(); itTow++) { itTow->step(delta.get_ticks(), mouseX, mouseY, enemies); } for (itBul = bullets.begin(); itBul != bullets.end(); itBul++) { itBul->step(delta.get_ticks()); if(itBul->position_.x < 2) itBul = bullets.erase(itBul); } for (itEn = enemies.begin(); itEn != enemies.end(); itEn++) { itEn->step(delta.get_ticks(), paths, bullets, gases); if(itEn->health_ <= 0) { money += itEn->maxHealth_ / 5; itEn = enemies.erase(itEn); } if(itEn->position_.y < -32) { itEn = enemies.erase(itEn); } } enemyTimer += delta.get_ticks(); totalTime += delta.get_ticks()/1000.0f; if(enemyTimer > enemyTime) { enemyCount++; enemyProb = max(sin(2 * M_PI / 10 *totalTime), (double)0.0); test.health_ *= pow(2, 1/50.0f); randomVal = rand()/(float)RAND_MAX; if(randomVal < enemyProb) { enemies.push_back(test); enemyTimer = 0; enemyTime -= 10; } } //restart timer delta.start(); //draw ss.str(string()); itEn = enemies.begin(); ss << "X: " << mouseX << " Y: " << mouseY << " " << itEn->health_ << " "; draw_MyRect(0, 0, 896, 896, 255, 255, 255, screen); draw_surface(Zero, background, screen); MyRect MyRect = {50, 50, 0, 0}; draw_text(500-200+64, 50, ss.str(), arial18, textColor, screen); draw_MyRect(768, 0, 128, 896, 0, 255, 255, screen); draw_MyRect(768, 0, 128, 64, 0, 200, 200, screen); draw_text(768+16, 16, "MENU", arial32, textColor, screen); ss.str(string()); ss << "Money: " << randomVal; draw_text(768+16, 16 + 32 + 16, ss.str(), arial18, textColor, screen); //ME draw_MyRect(800, 96, 64, 64, 255, 0, 0, screen); SDL_Rect tmpr = {0, 0, 32, 32}; MyRect.x = 768 + 32 + 32 - 16; MyRect.y = 64 + 32 + 32 -16; draw_surface(MyRect, tower, screen, &tmpr); //EE draw_MyRect(800, 96 + 72, 64, 64, 0, 0, 128, screen); MyRect.x = 768 + 32 + 32 - 16; MyRect.y = 64 + 32 + 32 -16 + 72; draw_surface(MyRect, tower, screen, &tmpr); //Che draw_MyRect(800, 96 + 72 + 72, 64, 64, 34, 177, 76, screen); MyRect.x = 768 + 32 + 32 - 16; MyRect.y = 64 + 32 + 32 -16 + 72 + 72; draw_surface(MyRect, tower, screen, &tmpr); //draw_lightning(0, 0, 500, 500, 50, yellow); //test.draw(); for (itEn = enemies.begin(); itEn != enemies.end(); itEn++) { itEn->draw(); } for (itPath = paths.begin(); itPath != paths.end(); itPath++) { itPath->draw(); } for (itBul = bullets.begin(); itBul != bullets.end(); itBul++) { itBul->draw(); } for (itGas = gases.begin(); itGas != gases.end(); itGas++) { itGas->draw(); } for (itTow = towers.begin(); itTow != towers.end(); itTow++) { itTow->draw(mouseX, mouseY); } SDL_Flip(screen); //SDL_Delay(10); } SDL_Quit(); SDL_FreeSurface(background); TTF_Quit(); output.close(); return 0; }
int main() { //the next few lines are to set unbuffered cin //it means you don't have to press [enter] in the keyboard // tcgetattr(STDIN_FILENO,&old_t);//gets the current terminal setings. new_t=old_t; new_t.c_lflag &=(~ICANON & ~ECHO);//disable ... tcsetattr(STDIN_FILENO,TCSANOW,&new_t);//set new settings unbuffered // ***************************************************** size_t number_partidas; size_t number_projects=0; while(1) { main1=&main2; char option=main1->menu(); bool ok; switch(option) { case 'w': //write a new partida /* restore the former settings */ tcsetattr(STDIN_FILENO,TCSANOW,&old_t);//buffered keyboard ok = true; try { main1 -> enter_data ();//we've filled a new object } catch(const char* e) { cout<<"errooooor !!!!!!"<<endl; cout << endl << e << endl; ok = false; } if(ok) { cont_main2.insert(main2); // int a=3; if(!project.size()) project.push_back(cont_main2); else { project.pop_back(); project.push_back(cont_main2); } } else cout << "I have inserted no partida"; tcsetattr(STDIN_FILENO,TCSANOW,&new_t);//set new settings unbuffered break; case 'p': //see a specific partida cout << "\n\n"; // string part=main2.partida; /* restore the former settings */ tcsetattr(STDIN_FILENO,TCSANOW,&old_t);//keyboard buffered cin>>main2.parti; tcsetattr(STDIN_FILENO,TCSANOW,&new_t);//set new settings unbuffered //converses string to float main2.find_partida(main2.parti);//find out the actual number cout << fixed << setprecision(2);//only 2 decimals // main2.find_partida(main2.partida); p=cont_main2.find(main2);//it is in cont_main2 if(p != cont_main2.cend()) { main2 = *p; main1 = &main2; //main1->print_partida(main2);//p contains a object (partida main1 -> print_partida(main2);//p contains a object (partida cout << "\nEdit ? (y/n)"; char ed; cin >> ed; if(ed == 'y' || ed == 'Y')main1->edit(); } else cout << "\n\nNot found !!!!" << endl; break; case 'e': //edit a specific partida break; case 's': //we want to save th whole set, not only one object file.open("prevision.bin",ios_base::out | ios_base::binary); if(file.is_open()) { number_partidas = cont_main2.size(); // static size_t number_projects=0; // number_projects=project.size(); //the first byte in disk will be the number of objects/partidas.. next the objects file.write(reinterpret_cast<const char*>(&(number_partidas)),sizeof(number_partidas)); //the second byte will contain the number of projectd // file.write(reinterpret_cast<const char*>(&(number_projects)),sizeof(number_projects)); p=cont_main2.cbegin();//point to the begining of the vector (dinamic array) main2=*p; main1=&main2; // main1 -> saveMonths(); for(size_t x = 0 ; x < number_partidas ; ++x) { main2 = *p; main1 -> save_file();//p contains an object a partida...saves ONE object/partida ++p;//next object ... next partida } } file.close(); cout << "\n*** FILE SAVED ***\n"; break; case 'l': file.open("prevision.bin",ios_base::in | ios_base::binary); if(file.is_open()) { cont_main2.erase(cont_main2.begin(),cont_main2.end()); int numberPartidas;//we read the number of objects/partidas file.read((char*)&numberPartidas,sizeof(numberPartidas) ); for(int x = 0;x < numberPartidas; ++x) main1 -> load_partida(); project.push_back(cont_main2); } file.close(); cout << "\n*** FILE LOADED ***\n"; break; case 'i': number_partidas = cont_main2.size(); p_project = project.begin(); // p=cont_main2.begin(); cout << endl << "List:" << endl; number_projects = project.size(); static size_t indexProjects; indexProjects=0; for(size_t proj = 0 ; proj < number_projects ; ++proj) { p = (*p_project).begin();//??????????????? cont_main2=*(project.begin()); p=cont_main2.begin();//ok !!!!!! // main1 -> headProjectMonth(indexProjects); for(size_t x = 0 ; x<number_partidas ; ++x) { main1 -> list();//writes one line/partida ++p; } cout << endl << endl; ++p_project; ++indexProjects; } cout << "\n\033[0;0mWould you like to create a monthly prevision from this list?" << "\033[?25h"; char a; cin.clear(); cout << "\033[?25l"; cin >> a; if(a =='y' || a =='Y') { project.push_back(cont_main2); //now we should save this container of containers on HDD //so..... ++number_projects; p_project=--project.end();//points past end so -- //no it point to the last set (the last budget) cont_main2 = *p_project;//a contains a set a month //we go to the begin(). The firs partida of this new monthly //budget.. Because the variable "month" is static. //only storing in the first line we are storing the month of //every partida. main2 = *cont_main2.begin();//main 2 contains a line a single partida main1 = &main2; cout << "\033[?25h"; char monthLastPrevision[] = "MArch"; buffered(); cout << "\nWhat month? "; cin >> monthLastPrevision; //we enter this month in the vector months main1 -> enterMonth (monthLastPrevision); unbuffered();//cin unbuffered (keyboard) cout << "\033[?25l";//hide cursor }
bool LogisticRegression::loadLegacyModelFromFile( fstream &file ) { string word; file >> word; if(word != "NumFeatures:") { errorLog << "loadLegacyModelFromFile( fstream &file ) - Could not find NumFeatures!" << endl; return false; } file >> numInputDimensions; file >> word; if(word != "NumOutputDimensions:") { errorLog << "loadLegacyModelFromFile( fstream &file ) - Could not find NumOutputDimensions!" << endl; return false; } file >> numOutputDimensions; file >> word; if(word != "UseScaling:") { errorLog << "loadLegacyModelFromFile( fstream &file ) - Could not find UseScaling!" << endl; return false; } file >> useScaling; ///Read the ranges if needed if( useScaling ) { //Resize the ranges buffer inputVectorRanges.resize(numInputDimensions); targetVectorRanges.resize(numOutputDimensions); //Load the ranges file >> word; if(word != "InputVectorRanges:") { file.close(); errorLog << "loadLegacyModelFromFile( fstream &file ) - Failed to find InputVectorRanges!" << endl; return false; } for(UINT j=0; j<inputVectorRanges.size(); j++) { file >> inputVectorRanges[j].minValue; file >> inputVectorRanges[j].maxValue; } file >> word; if(word != "OutputVectorRanges:") { file.close(); errorLog << "loadLegacyModelFromFile( fstream &file ) - Failed to find OutputVectorRanges!" << endl; return false; } for(UINT j=0; j<targetVectorRanges.size(); j++) { file >> targetVectorRanges[j].minValue; file >> targetVectorRanges[j].maxValue; } } //Resize the weights w.resize(numInputDimensions); //Load the weights file >> word; if(word != "Weights:") { errorLog << "loadLegacyModelFromFile( fstream &file ) - Could not find the Weights!" << endl; return false; } file >> w0; for(UINT j=0; j<numInputDimensions; j++) { file >> w[j]; } //Resize the regression data vector regressionData.resize(1,0); //Flag that the model has been trained trained = true; return true; }
size_t RenderV2ToFile(const ID3_TagImpl& tag, fstream& file) { ID3D_NOTICE( "RenderV2ToFile: starting" ); if (!file) { ID3D_WARNING( "RenderV2ToFile: error in file" ); return 0; } String tagString; io::StringWriter writer(tagString); id3::v2::render(writer, tag); ID3D_NOTICE( "RenderV2ToFile: rendered v2" ); const char* tagData = tagString.data(); size_t tagSize = tagString.size(); // if the new tag fits perfectly within the old and the old one // actually existed (ie this isn't the first tag this file has had) if ((!tag.GetPrependedBytes() && !ID3_GetDataSize(tag)) || (tagSize == tag.GetPrependedBytes())) { file.seekp(0, ios::beg); file.write(tagData, tagSize); } else { String filename = tag.GetFileName(); #if !defined HAVE_MKSTEMP // This section is for Windows folk FILE *tempOut = tmpfile(); if (NULL == tempOut) { // log this return 0; //ID3_THROW(ID3E_ReadOnly); } fwrite(tagData, 1, tagSize, tempOut); file.seekg(tag.GetPrependedBytes(), ios::beg); uchar tmpBuffer[BUFSIZ]; while (!file.eof()) { file.read((char *)tmpBuffer, BUFSIZ); size_t nBytes = file.gcount(); fwrite(tmpBuffer, 1, nBytes, tempOut); } rewind(tempOut); openWritableFile(filename, file); while (!feof(tempOut)) { size_t nBytes = fread((char *)tmpBuffer, 1, BUFSIZ, tempOut); file.write((char *)tmpBuffer, nBytes); } fclose(tempOut); #else // else we gotta make a temp file, copy the tag into it, copy the // rest of the old file after the tag, delete the old file, rename // this new file to the old file's name and update the handle String sTmpSuffix = ".XXXXXX"; if (filename.size() + sTmpSuffix.size() > ID3_PATH_LENGTH) { // log this return 0; //ID3_THROW_DESC(ID3E_NoFile, "filename too long"); } char sTempFile[ID3_PATH_LENGTH]; strcpy(sTempFile, filename.c_str()); strcat(sTempFile, sTmpSuffix.c_str()); int fd = mkstemp(sTempFile); if (fd < 0) { remove(sTempFile); //ID3_THROW_DESC(ID3E_NoFile, "couldn't open temp file"); } ofstream tmpOut(fd); if (!tmpOut) { tmpOut.close(); remove(sTempFile); return 0; // log this //ID3_THROW(ID3E_ReadOnly); } tmpOut.write(tagData, tagSize); file.seekg(tag.GetPrependedBytes(), ios::beg); uchar tmpBuffer[BUFSIZ]; while (file) { file.read(tmpBuffer, BUFSIZ); size_t nBytes = file.gcount(); tmpOut.write(tmpBuffer, nBytes); } tmpOut.close(); file.close(); remove(filename.c_str()); rename(sTempFile, filename.c_str()); openWritableFile(filename, file); #endif } return tagSize; }
int main(int argc, char* argv[]) { koordinate.open("F:/TRAKASNIMCI/log.txt",fstream::app); //pauza i resume koda bool pause = false; //kalibracija boja bool calibrationMode = true; //UPUTSTVO cout<<"CONTROLS\n"; cout<<"************************************\n"; cout<<"Press C to reset UKUPNO and SVI \n"; cout<<"Press P to pause program \n"; cout<<"************************************\n"; cout<<"Press M to enter manual record mode\n"; cout<<"Press A to return to automatic record mode \n"; cout<<"Press N to start new record \n"; cout<<"************************************\n"; cout<<"Current record mode > AUTOMATIC\n"; cout<<"************************************\n"; //Matrix to store each frame of the webcam feed Mat cameraFeed; Mat threshold; Mat HSV; capture.open(0); if(calibrationMode){ //kreiraj slajdere na treshold prozoru createTrackbars(); } else { //kreiraj slajdere na glavnom prozoru pokretna traka trackbarWaitkey(); } capture.set(CV_CAP_PROP_FRAME_WIDTH,FRAME_WIDTH); capture.set(CV_CAP_PROP_FRAME_HEIGHT,FRAME_HEIGHT); //Video writer VideoWriter oVideoWriter;//create videoWriter object, not initialized yet double dWidth = capture.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video double dHeight = capture.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video //set framesize for use with videoWriter Size frameSize(static_cast<int>(dWidth), static_cast<int>(dHeight)); if(!capture.isOpened()){ cout<<"GRESKA PRILIKOM PREUZIMANJA VIDEA\n"; getchar(); return -1; } Objekat crven("crven"), zelen("zelen"), zut("zut"), plav("plav"); //start an infinite loop where webcam feed is copied to cameraFeed matrix //all of our operations will be performed within this loop while(1){ //store image to matrix capture.read(cameraFeed); //convert frame from BGR to HSV colorspace cvtColor(cameraFeed,HSV,COLOR_BGR2HSV); if(calibrationMode==true){ //if in calibration mode, we track objects based on the HSV slider values. inRange(HSV,Scalar(H_MIN,S_MIN,V_MIN),Scalar(H_MAX,S_MAX,V_MAX),threshold); morphOps(threshold); imshow(thresholdWindow,threshold); trackFilteredObject(threshold,HSV,cameraFeed); } else { //crni kvadrat rectangle(cameraFeed,Point(200,380),Point(650,460),crBoja,-1); //crvene inRange(HSV,crven.getHSVmin(),crven.getHSVmax(),threshold); //morphOps(threshold); trackFilteredObject(crven,threshold,HSV,cameraFeed); //zute inRange(HSV,zut.getHSVmin(),zut.getHSVmax(),threshold); //morphOps(threshold); trackFilteredObject(zut,threshold,HSV,cameraFeed); //zelene inRange(HSV,zelen.getHSVmin(),zelen.getHSVmax(),threshold); //morphOps(threshold); trackFilteredObject(zelen,threshold,HSV,cameraFeed); //plave inRange(HSV,plav.getHSVmin(),plav.getHSVmax(),threshold); //morphOps(threshold); trackFilteredObject(plav,threshold,HSV,cameraFeed); line(cameraFeed,Point(xMIN,0),Point(xMIN,480),crBoja,2,8,0); line(cameraFeed,Point(xMAX,0),Point(xMAX,480),beBoja,2,8,0); //ISPIS DATUMA I VREMENA rectangle(cameraFeed,Point(0,460),Point(200,480),beBoja,-1); putText(cameraFeed,getDateTime(),Point(0,480),1,1,Scalar(0,0,0),2); //ukupno crvenih putText(cameraFeed,"UKUPNO",cv::Point(200,440),1,1,cBoja); putText(cameraFeed,intToString(cr.size()),cv::Point(200,460),1,1,cBoja); //ukupno zelenih putText(cameraFeed,"UKUPNO",cv::Point(300,440),1,1,zeBoja); putText(cameraFeed,intToString(ze.size()),cv::Point(300,460),1,1,zeBoja); //ukupno zutih putText(cameraFeed,"UKUPNO",cv::Point(400,440),1,1,zuBoja); putText(cameraFeed,intToString(zu.size()),cv::Point(400,460),1,1,zuBoja); //ukupno plavih putText(cameraFeed,"UKUPNO",cv::Point(500,440),1,1,pBoja); putText(cameraFeed,intToString(pl.size()),cv::Point(500,460),1,1,pBoja); //ukupno svi putText(cameraFeed,"SVI",cv::Point(600,440),1,1,beBoja); putText(cameraFeed,intToString(pl.size()+cr.size()+ze.size()+zu.size()),cv::Point(600,460),1,1,beBoja); } if(startRecording == true) { oVideoWriter = VideoWriter("F:/TRAKASNIMCI/Video"+intToString(inc)+".avi", CV_FOURCC('D', 'I', 'V', '3'), 15, frameSize, true); //initialize the VideoWriter object cout<<"New video file created F:/TRAKASNIMCI/Video"+intToString(inc)+".avi "<<endl; startRecording = false; if ( !oVideoWriter.isOpened() ) //if not initialize the VideoWriter successfully, exit the program { cout << "ERROR: Failed to initialize video writing" << endl; getchar(); return -1; } } //automatsko snimanje if(manualRecordingMode == false) { if(recording) { oVideoWriter.write(cameraFeed); //show "REC" in top left corner in red //be sure to do this AFTER you write to the file so that "REC" doesn't show up //on the recorded video. putText(cameraFeed,"REC",Point(0,60),1,2,Scalar(0,0,255),2); } } //manualno snimanje if(manualRecordingMode == true) { if(recordingM) { oVideoWriter.write(cameraFeed); //show "REC" in top left corner in red //be sure to do this AFTER you write to the file so that "REC" doesn't show up //on the recorded video. putText(cameraFeed,"mREC",Point(0,60),1,2,Scalar(0,0,255),2); } } //prikaz videa imshow(originalWindow,cameraFeed); //imshow(hsvWindow,HSV); //imshow(thresholdWindow,threshold); //KONTROLA switch(waitKey(milisek)){ case 27: //'esc' key has been pressed, exit program. return 0; case 112: //'p' has been pressed. this will pause/resume the code. pause = !pause; if(pause == true){ cout<<"Code paused, press 'p' again to resume\n"; cout<<"****************************************\n"; while (pause == true){ //stay in this loop until switch (waitKey()){ //a switch statement inside a switch statement? Mind blown. case 112: //change pause back to false pause = false; cout<<"Code Resumed\n"<<endl; cout<<"****************************************\n"; break; } } case 114: //'r' has been pressed. //toggle recording mode if(manualRecordingMode) { recordingM = true; cout << "Recording Started\n" << endl; cout<<"****************************************\n"; } break; case 115: //'s' has been pressed. //toggle recording mode if(manualRecordingMode) { recordingM = false; cout << "Recording Stopped, press R to continue recording to"<< "Video"<<intToString(inc) << "\n or press N to save current video and start recording new video\n"; cout<<"****************************************\n"; } break; case 99: //'c' has been pressed cr.clear(); ze.clear(); zu.clear(); pl.clear(); cout<<"Counters reseted\n"; cout<<"****************************************\n"; break; case 109: //'m' has been pressed //Manual recording manualRecordingMode = true; cout << "Manual recording mode \n New Video recording started, press R to record\n" << endl; cout<<"****************************************\n"; //increment video file name inc+=1; break; case 97: manualRecordingMode = false; cout<<" Automatic recording mode \n"; cout<<"****************************************\n"; break; case 110: //'n' has been pressed //start new video file startRecording = true; cout<<"NOW RECORDING \n"; cout<<"****************************************\n"; //increment video file name inc+=1; break; } } } capture.release(); koordinate.close(); return 0; }
void Logger::closeLog(fstream &file) { if (file.is_open()) file.close(); }
void student::write() { f1.open("file.txt",ios::out|ios::app); f1>>buffer; f1.close(); }
void perm(char *a,int m,int n) { char str[80] = "http://wecht.in/"; int r,z; if (m == n) { x=x+1; strcat(str, a); textcolor(14); cout<<"Link "; textcolor(12); cout<<x; textcolor(14); cout<<" : "; textcolor(10); cout<<str; textcolor(13); cout<<" Status "; textcolor(11); // system(str); //-//-------------------------------------------------------------------------------------------------------- //cout<<InternetCheckConnection("http://www.google.com",FLAG_ICC_FORCE_CONNECTION,0); /*if(!(InternetCheckConnection("http://www.google.com",FLAG_ICC_FORCE_CONNECTION,0))) { textcolor(3); cout<<"\n\nNet is not available or Connection is limited\nProgram is exiting in 3 seconds\n"; wait(3); exit(0); }*/ HINTERNET connect = InternetOpen("MyBrowser",INTERNET_OPEN_TYPE_PRECONFIG,NULL, NULL, 0); if(!(InternetCheckConnection("http://www.google.com",FLAG_ICC_FORCE_CONNECTION,0))) { textcolor(3); cout<<"\nInternet not connected or Connection is limited\nProgram is exiting in 3 seconds\n"; wait(3); exit(0); } HINTERNET OpenAddress = InternetOpenUrl(connect,str, NULL, 0, INTERNET_FLAG_PRAGMA_NOCACHE|INTERNET_FLAG_KEEP_CONNECTION, 0); //cout<<OpenAddress; if (!OpenAddress ) { DWORD ErrorNum = GetLastError(); cout<<"Internal error , Error No : "<<ErrorNum<<endl; fs_obj.open("wecht.txt",ios::out | ios::app); fs_obj<<"Link "<<x<<" : "<<str<<" Status Internal error , Error No : "<<ErrorNum<<endl; fs_obj.close(); InternetCloseHandle(connect); //system("pause"); //wait(4); //exit(0); } z=0; char DataReceived[80]; DWORD NumberOfBytesRead = 0; while(InternetReadFile(OpenAddress, DataReceived, 80, &NumberOfBytesRead) && NumberOfBytesRead ) { z=z+1; //textcolor(15); //cout<<z<<" "; //textcolor(11);//<<strlen(DataReceived)<<endl; //cout<<DataReceived; } /*if((z<29)&&(z>22)) { fs_obj.open("wecht.txt",ios::out | ios::app); cout<<"Link expired :-(\n"; fs_obj<<"Link "<<x<<" : "<<str<<" Status Link expired :-( "<<endl; fs_obj.close(); z=0;//getch(); }*/ if((z<41)&&(z>34)||(z==9)) { fs_obj.open("wecht.txt",ios::out | ios::app); fs_obj<<"Link "<<x<<" : "<<str<<" Status Link exist :-) "<<endl; fs_obj.close(); fs_link.open("Link_exist.txt",ios::out | ios::app); fs_link<<str<<endl; fs_link.close(); cout<<"\n\nLink exist in the combination of these unique word , now start this program again and enter another 5 unique word\n\nPress any key to end the program\n"; z=0; getch(); exit(0); } else { fs_obj.open("wecht.txt",ios::out | ios::app); cout<<"Link do not exist :-(\n"; fs_obj<<"Link "<<x<<" : "<<str<<" Status Link do not exist :-( "<<endl; fs_obj.close(); z=0;//getch(); } InternetCloseHandle(OpenAddress); InternetCloseHandle(connect); wait(3); //-//---------------------------------------------------------------------------*/ } else { for (r = m; r <= n; r++) { swap((a+m), (a+r)); perm(a, m+1, n); swap((a+m), (a+r)); //backtrack } } }