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


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

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


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

示例1: SaveOBJ

bool SaveOBJ(ofstream& fout, const double* const& points, const int* const& triangles, const unsigned int& nPoints,
    const unsigned int& nTriangles, const Material& material, IVHACD::IUserLogger& logger, int convexPart, int vertexOffset)
{
    if (fout.is_open()) {

        fout.setf(std::ios::fixed, std::ios::floatfield);
        fout.setf(std::ios::showpoint);
        fout.precision(6);
        size_t nV = nPoints * 3;
        size_t nT = nTriangles * 3;

		fout << "o convex_" << convexPart << std::endl;

        if (nV > 0) {
            for (size_t v = 0; v < nV; v += 3) {
                fout << "v " << points[v + 0] << " " << points[v + 1] << " " << points[v + 2] << std::endl;
            }
        }
        if (nT > 0) {
            for (size_t f = 0; f < nT; f += 3) {
                     fout << "f " 
                     << triangles[f + 0]+vertexOffset << " "
                     << triangles[f + 1]+vertexOffset << " "
                     << triangles[f + 2]+vertexOffset << " " << std::endl;
            }
        }
        return true;
    }
    else {
        logger.Log("Can't open file\n");
        return false;
    }
}
开发者ID:BlackToppStudios,项目名称:Mezzanine,代码行数:33,代码来源:main.cpp

示例2: main

int main()
{

  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(2);
 
  int i,j,t;
  double tmp;
  cin>>t;
  while(t > 0)
    {
      cin>>n>>tmp;
      m = tmp * 100.00000000 + 0.5;
      for( i = 1 ; i <= n ; ++ i)
	{
	  cin>>w[ i ]>>v[ i ];
	  v[ i ] = v[ i ] * 100 + 0.5;
	}
      
      for( i = 1 ; i <= n ; ++ i)
	for( j = int( m ) ;j >= int(v[ i ]) ; -- j)
	  if( f[ j ] < f[ j - int(v[ i ]) ] + w[ i ] )
	    f[ j ] = f[ j - int(v[ i ]) ] + w[ i ];	
      cout<<f[ int(m) ]<<"\n";  
      for( i = int( m ) ; i >= 0 ; -- i ) f[ i ] = 0; 
      --t;
    }
  return 0;
}
开发者ID:gestapolur,项目名称:Gestapolur-Code-Storage,代码行数:30,代码来源:gprob002.cpp

示例3: setPrintPrecision

void setPrintPrecision(int print_precision, ofstream& out) {
    cout.setf(std::ios::scientific);
    cout.precision(print_precision);
    out.setf(std::ios::fixed);
    out.precision(print_precision);
    out.setf(ios::showpoint);
}
开发者ID:lstagner,项目名称:Symplectic-Guiding-Center,代码行数:7,代码来源:symplectic.cpp

示例4: percentDiff

void percentDiff(double valA, double valB, ofstream& foutA)
{
	double result;

	result = ( fabs(valA - valB) / ( (valA + valB) / 2) ) * 100;

	foutA.setf(ios::fixed);
	foutA.setf(ios::showpoint);
	foutA.precision(2);
	foutA << setw(15) << result << " %" << endl;
	foutA.precision(6);

} // end of percent diff
开发者ID:Nick177,项目名称:Speech_Signal_Analysis,代码行数:13,代码来源:speechSignalAnalysis.cpp

示例5: work

/*
Example:
After applying work():
  1: MPI_Bcast= (void buffer= 1198516368, int count= 80, MPI_Datatype datatype= 1247288704, int root= 0,
                 MPI_Comm comm= 6604320, )S=[ 1367981215084679 ] E=[ 1367981215086238 ] D=[ 1559 ]
*/
void work()
{
    string s;
    int count = 0;

    double startTime, endTime, durTime;

    getline(fin ,s);
    while (fin)
    {
        count++;
        fout << count << ": ";

        char *str  = (char *) s.c_str();
        char *p = strtok(str, " ");

        startTime = atof(p);

        p = strtok(NULL, " ");
        string funcName(p);
        fout << funcName << "= ";

        p = strtok(NULL, " ");
        string funcArgs(p);
        fout << funcArgs ;

        fout.setf(ios::fixed);
        fout << "S=[ " << startTime << " ] ";

        p = strtok(NULL, " ");
        string ret_value(p);
        fout.setf(ios::fixed);
        fout << "R=[ " << ret_value << " ] ";

        p = strtok(NULL, " ");
        durTime = atof(p);
        endTime = startTime + durTime;


        fout << "E=[ " << endTime << " ] ";

        fout << "D=[ " << durTime << " ] ";

        fout << std::endl;

        getline(fin ,s);
    }
}
开发者ID:HDFGroup,项目名称:Replayer,代码行数:54,代码来源:trace2symbol.cpp

示例6: Fini

// This function is called when the application exits
VOID Fini(INT32 code, VOID *v)
{
    if (icount1 != icount2 || icount1 != icount3 || icount1 != icount4 || icount1 != icount5
        || thenCount!=0)
    {
        // Write to a file since cout and cerr maybe closed by the application
        OutFile.open(KnobOutputFile.Value().c_str());
        OutFile.setf(ios::showbase);
        if (thenCount!=0)
        {
            OutFile << "****ERROR thenCount was expected to be 0  not: " << thenCount << endl;
        }
        else
        {
            OutFile << "Count1 " << icount1 << endl;
            OutFile << "Count2 " << icount2 << endl;
            OutFile << "Count3 " << icount3 << endl;
            OutFile << "Count4 " << icount3 << endl;
            OutFile << "Count5 " << icount3 << endl;
            OutFile << "***ERROR - mismatch in icounts " << endl;
        }
        OutFile.close();
        exit (1);
    }
}
开发者ID:alugupta,项目名称:resilient-systems,代码行数:26,代码来源:inscount_for_lea_opt.cpp

示例7: 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

示例8: Fini

// This function is called when the application exits
VOID Fini(INT32 code, VOID *v)
{
    // Write to a file since cout and cerr maybe closed by the application
    OutFile.setf(ios::showbase);
    OutFile << "Count " << icount << endl;
    OutFile.close();
}
开发者ID:alagenchev,项目名称:school_code,代码行数:8,代码来源:inscount1.cpp

示例9: main

int main(int argc, CHAR *argv[])
{
    char * s = getenv("LD_ASSUME_KERNEL");
    if (s == 0)
        printf("LD_ASSUME_KERNEL not set\n");
    else if (strcmp(s,"2.4.1") != 0)
        printf("LD_ASSUME_KERNEL is wrong: %s\n",s);

    PIN_InitSymbols();

    if( PIN_Init(argc,argv) )
    {
        return Usage();
    }

    TraceFile.open(KnobOutputFile.Value().c_str());
    TraceFile << hex;
    TraceFile.setf(ios::showbase);

    IMG_AddInstrumentFunction(ImageLoad, 0);
    
    PIN_StartProgramProbed();
    
    return 0;
}
开发者ID:gungun1010,项目名称:hidden,代码行数:25,代码来源:probe2.cpp

示例10: PutTable

/** Put a table of node values.  This table is as compact
    as possible while still maintaining readability
*/
void NodeList::PutTable( ofstream& s )
{
  s.precision(4);
  s.setf( ios::right, ios::adjustfield );
  
  s << GNU_COMMENT << " NodeList\n"
    << GNU_COMMENT << "=========\n";
  
  s << GNU_COMMENT << ' '
    << setw( 6) << "Id(1) "
    << setw(13) << "x(2) "
    << setw(13) << "fluxS(3) "
    << setw(13) << "fluxD(4) "
    << setw(13) << "fluxE(5) "
    << setw(13) << "left id(6) "
    << setw(13) << "right id(6) "
    << '\n';
  
  SetLineStyle( '-' );
  PutLine( s, 106 );
  
  for( int i=0; i<n; i++ ){
    node[i].PutTable( s );
  }
  s.flush();
}
开发者ID:patrickjmann,项目名称:rshock1d_god5,代码行数:29,代码来源:Node.C

示例11: main

int main(int argc, char* argv[])
{
  if ( PIN_Init(argc, argv) ) 
    return Usage();
  PIN_InitSymbols();

  // Initialize trace
  trace.open(KnobOutputFile.Value().c_str());
  trace << hex;
  trace.setf(ios::showbase);

  // Intialize stack tracing code
  IMG_AddInstrumentFunction(I_ImageLoad, 0);
  TRACE_AddInstrumentFunction(I_Trace, 0);

  // Initialize memory tracing code
  INS_AddInstrumentFunction(Instruction, 0);
  IMG_AddInstrumentFunction(Image, 0);

  // Initialize cleanup code
  PIN_AddFiniFunction(Fini, 0);

  PIN_StartProgram();
  assert(false && "Control should never reach here!");

  return 0;
}
开发者ID:andrewjinyounglee,项目名称:PerVERT,代码行数:27,代码来源:pervert.cpp

示例12: outputNet

//Output values for neural network
void outputNet(neuNet network, ofstream &output) {
	output.setf(ios::fixed,ios::floatfield);
	output.precision(3);
	
	output << network.input.size() << " "; //output number of inputs
	output << network.hidden.size() << " "; //output number of hidden nodes
	output << network.output.size() << endl; //output number of outputs
	
	//output weights of input-hidden node edges
	for (int i = 0; i < network.hid_in.size(); ++i) {
		for (int j = 0; j < network.hid_in[i].size(); ++j) {
			//if-else to prevent placing space at end of line
			if (j != network.hid_in[i].size()-1)
				output << "input hidden: " << network.hid_in[i][j] << " ";
			else
				output << "input hidden: " << network.hid_in[i][j];
		}
		output << endl;
	}
	
	//output weights of hidden node-output edges
	for (int i = 0; i < network.out_hid.size(); ++i) {
		for (int j = 0; j < network.out_hid[i].size(); ++j) {
			//if-else to prevent placing space at end of line
			if (j != network.out_hid[i].size()-1)
				output << "output weight: " << network.out_hid[i][j] << " ";
			else
				output << "output weight: " << network.out_hid[i][j];
		}
		output << endl;
	}
}
开发者ID:niangaotuantuan,项目名称:iris-classifier,代码行数:33,代码来源:training.cpp

示例13: write

void write(ofstream& out, Car c[], int size)
{
    for(int i=0; i < size; i++)
    {
        Car CAR = c[i];
        
        out.setf(ios::fixed);
        out.setf(ios::showpoint);
        out.precision(2);
        
        out << CAR.make << " " << CAR.model << " " << CAR.year << " "
        << CAR.price << " " << CAR.miles  << " " << CAR.getValue() << endl;
    }
    
    return;
}
开发者ID:yuexx113,项目名称:HW7B,代码行数:16,代码来源:main.cpp

示例14: init_log

void init_log(const VolModel model, const RunMode runmode, ofstream& log_stream)
{
	string logfile = "./log_" + get_model_name(model) + "_" + get_run_mode(runmode);
	cout<<"log file is: "<<logfile<<endl;
	log_stream.open(logfile.c_str());
	log_stream.setf(ios::fixed);
	log_stream<<setprecision(10);
}
开发者ID:hildingur,项目名称:filtering,代码行数:8,代码来源:final_ekf.cpp

示例15: processing

void processing(ifstream& inFile, ofstream& outFile)
{	//variable declarations 
	char letter;
	double number, avg, sum(0);


	//sets precision and decimal place
	outFile.setf(ios::fixed);
	outFile.setf(ios::showpoint);
	outFile.precision(2);
	

	
	outFile << "********************************************" << endl
		<< "Student Name: ";

	
	//outputs name to result.txt
	while(letter != '\n')
	{
		inFile.get(letter);
		outFile.put(letter);
	}

	outFile << "Test Scores: ";


	//outputs scores and finds their sum
	inFile >> number;
	while(! inFile.eof( ))
	{
		
		sum += number;
		outFile << number << setw(8);
		inFile >> number;
		
	}

	//calculates average
	avg = sum / 5.0;
	outFile << endl << "Average Score: " << avg << endl
		<< "********************************************" << endl;
	
     
}
开发者ID:austinhofmann,项目名称:School,代码行数:45,代码来源:StudentGrade.cpp


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