当前位置: 首页>>代码示例>>C++>>正文


C++ ofstream::fail方法代码示例

本文整理汇总了C++中ofstream::fail方法的典型用法代码示例。如果您正苦于以下问题:C++ ofstream::fail方法的具体用法?C++ ofstream::fail怎么用?C++ ofstream::fail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ofstream的用法示例。


在下文中一共展示了ofstream::fail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fileclose

void a::fileclose(ofstream &out, Error &error) {
  if (out.fail()) {
    error.addwarning(10,15,"Misc","Error writing to output file!");
    error.writewarnings();
  }
  out.close();
}
开发者ID:behollis,项目名称:muViewBranch,代码行数:7,代码来源:misc.cpp

示例2: TryOpen

static void TryOpen(ofstream& f, const char* name){
    f.open(name);
    f.setf(ios::showbase);
    if (f.fail()){
        ErrorExit("cannot open output file: " << name, MetasimError_FileOp);
    }
}
开发者ID:amoghavs,项目名称:PEBIL,代码行数:7,代码来源:InstrumentationCommon.hpp

示例3: DllMain

BOOL WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID)
{
	if (reason == DLL_PROCESS_ATTACH) {
		original = LoadLibraryA("s7onlinx_.dll");
		if (original == 0) {
			return false;
		}

		original_send = GetProcAddress(original, "SCP_send");
		original_receive = GetProcAddress(original, "SCP_receive");

		determine_proxy_session();

		logfile.open(absolute_logfile_name, ofstream::out);

		if (logfile.fail()) {
			return false;
		}

		pcap_send = unique_ptr<Pcap>(new Pcap(absolute_sendcap_filename));
		pcap_recv = unique_ptr<Pcap>(new Pcap(absolute_recvcap_filename));
		pcap_amalgamation = unique_ptr<Pcap>(new Pcap(absolute_amalgamationcap_filename));

		log("Proxy initialized");

	} else if (reason == DLL_PROCESS_DETACH) {
		log("Proxy shutdown");
		FreeLibrary(original);
	}

	return true;
}
开发者ID:qhnetspirit,项目名称:s7onlinx-proxy,代码行数:32,代码来源:s7onlinx.cpp

示例4: switch_log

static bool switch_log(ofstream &flog)
{
    GenerateTime("pacs_log\\%Y\\%m\\%d\\%H%M%S_service_n.txt", buff, sizeof(buff));
    if(flog.tellp() > 10 * 1024 * 1024 || strncmp(buff, current_log_path.c_str(), 20)) // 20 == strlen("pacs_log\\YYYY\\MM\\DD\\")
    {
	    if(PrepareFileDir(buff))
        {
            if(flog.is_open())
            {
                time_header_out(flog) << "to be continued" << endl;
                flog.close();
            }
            flog.open(buff);
            if(flog.fail())
            {
                cerr << "watch_notify() switch log " << buff << " failed" << endl;
                return false;
            }
            time_header_out(flog) << "continuation of " << current_log_path << endl;
            current_log_path = buff;
        }
	    else
        {
            DWORD gle = GetLastError();
            cerr << "watch_notify() switch log failed, PrepareFileDir(" << buff << ") failed" << endl;
		    return false;
        }
    }
    return true;
}
开发者ID:zyinventory,项目名称:simple-ris,代码行数:30,代码来源:watch_notify.cpp

示例5: writeOut

bool HogWrapper::writeOut(ofstream &ofs)
{
  ofs << "<svlFeatureExtractor id=\"HogWrapper\" ";

  ofs << " version=\"1.0\" ";
  ofs << " width=\"" << _hog->winSize.width << "\" ";
  ofs << " height=\"" << _hog->winSize.height << "\" ";
  ofs << " blockWidth=\"" << _hog->blockSize.width << "\" ";
  ofs << " blockHeight=\"" << _hog->blockSize.height << "\" ";
  ofs << " blockStrideX=\"" << _hog->blockStride.width << "\" ";
  ofs << " blockStrideY=\"" << _hog->blockStride.height << "\" ";
  ofs << " nBins=\"" << _hog->nbins << "\" ";
  ofs << " derivAperture=\"" << _hog->derivAperture<<"\" ";
  ofs << " winSigma=\"" << _hog->winSigma<<"\" ";
  ofs << " histogramNormType=\"" << _hog->histogramNormType << "\" ";
  ofs << " L2HysThreshold=\"" << _hog->L2HysThreshold << "\" ";
  ofs << " gammaCorrection=\""<< (bool) _hog->gammaCorrection<<"\" ";
  ofs << " validChannel=\""<<_validChannel<<"\" ";
  ofs << " cellWidth=\""<<_hog->cellSize.width<<"\" ";
  ofs << " cellHeight=\""<<_hog->cellSize.height<<"\" ";


  ofs << "> " << endl;

  ofs << "</svlFeatureExtractor>" << endl;

  return !ofs.fail();
}
开发者ID:bk8190,项目名称:people_experimental,代码行数:28,代码来源:hogWrapper.cpp

示例6: writeFile

void writeFile(ofstream& fout) {
	fout.open("prettysonglist.txt");
	if(fout.fail()) {
		cout << "Couldn't write to file." << endl;
		exit(-1);
	}
}
开发者ID:reykjalin,项目名称:2015-3,代码行数:7,代码来源:dt05.cpp

示例7: openFiles

// open input and output files
// pre: user is prepared to enter file names at the keyboard
// post: files have been opened
void openFiles(ifstream &infile, ofstream &outfile)
{

	// open input data file
	string inFileName;
	cout << "Enter the name of the input file: ";
	cin >> inFileName;
	infile.open(inFileName.c_str());
	if (infile.fail()) {
		cout << "Error opening input data file" << endl;
		char junk;
		cout << "press enter to exit";
		junk = cin.get();
		junk = cin.get();
		exit(1);
	}

	// open output data file
	string outFileName;
	cout << "Enter the name of the output file: ";
	cin >> outFileName;
	outfile.open(outFileName.c_str());
	if (outfile.fail()) {
		cout << "Error opening output data file" << endl;
		char junk;
		cout << "press enter to exit";
		junk = cin.get();
		junk = cin.get();
		exit(1);
	}

}
开发者ID:leealbert95,项目名称:Reverse-Audio,代码行数:35,代码来源:reverse.cpp

示例8: open

 inline void open(const char *fn, ios_base::openmode mode) {
   s_fn.reset(fn); 
   ofs.open(fn, mode); 
   if (ofs.fail()) {
     throw new AzException(AzFileIOError, "AzOfs::open", "Failed to open:", fn); 
   }
 }
开发者ID:fukatani,项目名称:rgf_python,代码行数:7,代码来源:AzUtil.hpp

示例9: main

int main()
{
	mapgen.open("mapgen.txt");
	if (mapgen.fail())
	{
		cout << "can't open file" << endl;
		return 0;
	}

	srand(time(NULL));
	const int X = 20, Y = 20; //dimensions of the maze
	int **checkWall; //ptr to the two-dimensional array that determines walls and spaces
	int **checkVisited; //ptr to the two-dimensional array that stores whether a coordinate has been looked at

	checkWall = new int*[X];				//setting up the arrays to make the maze
	checkVisited = new int*[X];				//
											//
	for (int i = 0; i < X; i++)				//
	{										//	
		checkWall[i] = new int[X];			//
		checkVisited[i] = new int[X];		//
		for (int i = 0; i<Y; i++)			//
		{									//
			checkWall[i] = new int[Y];		//
			checkVisited[i] = new int[Y];	//
		}									//
	}										//

	initMap(X, Y, checkWall, checkVisited); // fills map with solid walls, sets checkVisited to zero(false) for all coordinates
	mapGen(checkWall, checkVisited, X, Y);	// generates the maze!


	for (int i = 0; i<20; i++)				//prints the maze to the screen, 'HHH' for wall, '   ' for space
	{										//
		for (int j = 0; j < X; j++) {		//
			if (checkWall[i][j])			//
				cout << "HHH";				//
			else							//
				cout << "   ";				//
		}									//
		cout << "HHH" << endl;				//
	}										//
	for (int i = -1; i < Y; i++)			//
		if (i == Y - 2)						//
			cout << "   ";					//
		else								//
			cout << "HHH";						//
	cout << endl;							//


	for (int j = 0; j < X; j++)				//deleting the zombies that made the maze
	{										//
		delete[] checkWall[j];				//
		delete[] checkVisited[j];			//
	}										//
	delete[] checkWall;						//
	delete[] checkVisited;					//
	mapgen.close();
}
开发者ID:Cmoore28,项目名称:CS172,代码行数:59,代码来源:Source.cpp

示例10: openwritefile

void openwritefile(ofstream& OutStream, string thefilename)
{
    OutStream.open(thefilename.c_str());
    if (OutStream.fail())
    {
        cout << "can't open the file: " << thefilename << endl;
        exit(1);
    }
}
开发者ID:reykjalin,项目名称:2015-3,代码行数:9,代码来源:main.cpp

示例11: open_file

void result::open_file()
{
    input.open(file_name);
    output.open("A.cht");
    if(input.fail())//if open fail,then finish
    {
        cout<<"Input file open fail"<<endl;
        exit(1);
    }
    if(output.fail())
    {
        cout<<"Output file open fail"<<endl;
        exit(1);
    }

    if(!input.fail() && !output.fail())
        cout<<"All file open success"<<endl;
}
开发者ID:fu908301,项目名称:OOP,代码行数:18,代码来源:change_file.cpp

示例12: openFile

 //Opens an output file that will contain a time series for N
 void openFile()
 {
     ostringstream os;
     os << "window_N=" << _N0 << ".txt";
     _ofile.open(os.str().c_str(), ios::app);
     if (_ofile.fail()) {
         cerr << "ERROR: Failed to open window " << _N0 << ".\n";
         exit(0);
     }        
 }
开发者ID:askeys,项目名称:tutorials,代码行数:11,代码来源:step1.cpp

示例13: open_ofstream

//creates the file that will have the changes
void open_ofstream (ofstream& name)
{
	name.open("C:\\Users\\Mufasa\\Desktop\\ENGLISH_AS_A_SECOND_LANGUAGE_aww_yeah_baby.rtf");
	if (name.fail())
	{
		cout << "Failed to connect to file & this program probaly did not create the file for you\n";
		system ("PAUSE");
		exit(1);
	}
	return;
}
开发者ID:Vacio,项目名称:NoncreditScheduler,代码行数:12,代码来源:Noncredit_schedule_formatter.cpp

示例14: open_ofstream_isd

//Connects to the file in the same directory
void open_ofstream_isd(ofstream& name)
{
	name.open("Nicely_formatted_text.txt");
	if (name.fail())
	{
		cout << "Failed to connect to file [middle finger]\n Perhaps the file is not in the same folder as the program";
		system ("PAUSE");
		exit(1);
	}
	return ;
}
开发者ID:Vacio,项目名称:NoncreditScheduler,代码行数:12,代码来源:Noncredit_schedule_formatter.cpp

示例15: connectOutputFile

void FileClass::connectOutputFile(ofstream & outputFile)
{
	string filename;
	getline(cin, filename);

	outputFile.open(filename);

	if (outputFile.fail()) {
		throw outputFileFail(filename); 
	}
}
开发者ID:Charile1,项目名称:File-Filter,代码行数:11,代码来源:FileClass.cpp


注:本文中的ofstream::fail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。