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


C++ ifstream::close方法代码示例

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


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

示例1: main

int main(int argc, char *argv[])
{
	preWork();
	QCoreApplication a(argc, argv);

//	char * inputName="A-large.in";
//	fin.open(inputName);
//	fin.open ( "A-small-practice.in");
	//fin.open ( "A-large-practice.in");
	fin.open ( "NO1_input.txt");
	
	fout.open("output.txt");
	int n;
	fin >>n;
	for (int i=0; i<n; i++)
	{
		fout<<"Case #"<<i+1<<": ";
		work();
		fout<<endl;
	}


	fin.close();

	fout.close();



//	return a.exec();
}
开发者ID:xh286286,项目名称:algorithm,代码行数:30,代码来源:main1_1.cpp

示例2: lista_neutral

void lista_neutral()
{
    int PDGpob;int numpom;
    for(short int i=0;i<nmax;i++){neutral[i]=0;}
    wczyt.open("neutral.txt");
    if(!wczyt){cout<<"Nie znaleziono pliku neutral.txt!\n";}
    else
    {
        int xx=0;
        while(!wczyt.eof())///odwo³ujemy siê do pliku z numerami PDG
        {
            ///pobranie numeru PDG
            PDGpob=0;
            wczyt.getline(linia,100);
            short int i=0,liczba;
            do
            {
                liczba=char_to_int(linia[i]);
                PDGpob*=10;PDGpob+=liczba;
                i++;
            }while(linia[i]!='#'&&linia[i]!='\0'&&i<100);
            if(PDGpob>0)
            {
                neutral[xx]=PDGpob;
                xx++;
            }
        }
    }
    wczyt.close();wczyt.clear();
}
开发者ID:tjel,项目名称:infpro-2,代码行数:30,代码来源:scade.cpp

示例3: lPDGrozpad

void lPDGrozpad()
{
    int PDGpob;int numpom;
    for(short int i=0;i<lPDGmax;i++){PDGrozpadane[i]=0;}
    wczyt.open("CMN.txt");
    while(!wczyt.eof())///odwo³ujemy siê do pliku z numerami PDG
    {
		///pobranie numeru PDG
        PDGpob=0;
        wczyt.getline(linia,100);
        short int i=0,liczba;
        do
        {
            liczba=char_to_int(linia[i]);
            PDGpob*=10;PDGpob+=liczba;
            i++;
        }while(linia[i]!='#'&&linia[i]!='\0'&&i<100);
        if(PDGpob>0)
        {
            PDGrozpadane[ilerozp]=PDGpob;
            ilerozp++;
        }
    }
    wczyt.close();wczyt.clear();
}
开发者ID:tjel,项目名称:infpro-2,代码行数:25,代码来源:scade.cpp

示例4:

main()
{

printf("Content-Type: text/html\n\n");

file.open(getenv("PATH_TRANSLATED"));

if(!file.is_open())
	{
	printf("Can't open file!");
	return 0;
	}
else
	{
	while(!file.eof())
		{
		file.getline(buffer, 1024);
		printf(buffer);
		printf("\n");
		}
	}

printf("<script type=\"text/javascript\" src=\"http://wht.org/wht/wht-ng_advertise.php?domain=");
printf(getenv("PATH_TRANSLATED"));
printf("\"> </script>");
file.close();

return 0;

}
开发者ID:carriercomm,项目名称:wht-ng,代码行数:30,代码来源:wht-ng_handler.cgi.out.c

示例5: getLineCoordV

void getLineCoordV(ifstream &myFile){

    while (!myFile.eof())
    {
      std::string myString;
      getline(myFile, myString);
	  int taille = myString.size() & INT_MAX;
	  if ((myString[0] == 'v') && (myString[1] == ' ')) {
        myString.erase(myString.begin(),myString.begin()+3);
		  int i = 0;
		  while (myString[i] == ' ') {
			  i++;
		  }
		  while (myString[i] != ' ') {
			  char c = myString[i];

			  tabvx.push_back(c);
			  i++;
		  }
		  while (myString[i] == ' ') {
			  i++;
		  }
		  while (myString[i] != ' ') {
			  char c = myString[i];
			  tabvy.push_back(c);
			  i++;
		  }
		  while (myString[i] == ' ') {
			  i++;
		  }
		  while (i < (taille + 1)) {
			  char c = myString[i];

			  tabvz.push_back(c);
			  i++;
		  }

		  std::string strx(tabvx.begin(), tabvx.end());
		  std::string stry(tabvy.begin(), tabvy.end());
		  std::string strz(tabvz.begin(), tabvz.end());
          double x = atof(strx.c_str());
          double y = atof(stry.c_str());
          double z = atof(strz.c_str());
		  tabv.push_back(x);
		  tabv.push_back(y);
		  tabv.push_back(z);
          taballv.push_back(tabv);
		  tabv.pop_back();
		  tabv.pop_back();
		  tabv.pop_back();
		  tabvx.clear();
		  tabvy.clear();
		  tabvz.clear();

	  }

  }
  myFile.close();
}
开发者ID:BallyB,项目名称:Infographie,代码行数:59,代码来源:main.cpp

示例6: main

int main(int argv,char*argc[])
{
    int v[3][3],res[3],r[3];
    for(int i = 0; i < 3; ++i) fin >> res[i];
    for(int j=0;j<3;++j)
    {
        for(int i = 0; i < 3; ++i) fin >> v[j][i];
    }
    bool flag;
    int ratio;
    for(r[0]=0;r[0]<=100;++r[0])
    {
        for(r[1]=0;r[1]<=100;++r[1])
        {
            for(r[2]=0;r[2]<=100;++r[2])
            {
                flag = true;
                ratio = 0;
                for(int i=0;i<3;++i)
                {
                    int temp=0;
                    for(int j=0;j<3;++j)
                    {
                        temp += r[j]*v[j][i];
                    }
                    if(res[i]==0 && temp!=0)flag=false;
                    else if(temp==0 && res[i]!=0) flag = false;
                    else if(temp==0 && res[i] == 0)
                    {
                        
                    }
                    else if(temp%res[i]!=0)flag=false;
                    else
                    {
                        if(ratio==0) ratio = temp/res[i];
                        else if(temp/res[i] != ratio) flag = false;
                    }
                }
                if(flag)
                {
                    for(int j=0;j<3;++j)
                    {
                        fout << r[j] << " " ;
                    }
                    fout << ratio << endl;
                    goto end;
                }
            }
        }
    }
    end:
    if(!flag)
    {
        fout << "NONE" << endl;
    }
    fin.close();
    fout.close();
    return 0;
}
开发者ID:GenguoWang,项目名称:usaco,代码行数:59,代码来源:ratios.cpp

示例7: getParams

void getParams(ifstream& configFile)
{
	const char delim = '=';
	const char comment = '#';

	string line;
	while (!configFile.eof()) {

		// Get line
		getline(configFile, line);
		if (line == "") continue;

		// Is this a comment?
		size_t commentPos = line.find(comment);
		if (commentPos != line.npos) {
			debugCout("Found a comment in the ini:" + line);

			// Is the whole line a comment?
			if (commentPos != 0) {
				line = line.substr(0, commentPos);
			}
			else {
				continue;
			}
		}

		// Split line on delim
		size_t delimPos = line.find(delim);
		if (delimPos != line.npos) {
			debugCout("getting param and value from line: '" + line + "'");
			string param = line.substr(0, delimPos);
			string value = line.substr(delimPos + 1);
			debugCout("param: '" + param + "' = '" + value + "'");

			// Look up param
			bool assigned = false;
			for (int i = 0; i < PARAM_COUNT; i++) {
				int equal = _strcmpi(param.c_str(),paramTags[i].c_str());
				if (equal == 0) {
					params[i] = stod(value);
					assigned = true;
					break;
				}
			}
			if (!assigned) {
				throw runtime_error("Parameter: '" + param + "'  not allowed");
			}
		}
		else {
			throw runtime_error("Invalid data: '" + line + "'");
		}
	}
	// Verify that we have all the params needed: -1 is default value of params before assignment
	vector<double>::iterator it = find(begin(params), end(params), -1);
	if (it != params.end()) {
		throw runtime_error("Missing parameter(s)");
	}
	configFile.close();
}
开发者ID:heed13,项目名称:CS3370,代码行数:59,代码来源:main.cpp

示例8: buildHeap

		void buildHeap(ifstream& input, ofstream& output){
			int data;
			while(input >> data){
				insertOneDataItem(data);
				printHeap(output);
			}
			input.close();
		}
开发者ID:OliverAkhtar,项目名称:Projects,代码行数:8,代码来源:Project4.cpp

示例9: fileClose

// closes the ifstream and returns wether the connection was
// successfully closed or not
bool fileHandler::fileClose (ifstream& inFile) {
    bool success = true;
    inFile.close();
    if (inFile.is_open())  {
        success = false;
    }
    return success;
}
开发者ID:BeauJoh,项目名称:ppm,代码行数:10,代码来源:filehandler.cpp

示例10: Compile

int32_t Compile( CParser* pParser, ifstream& fin)
{
	//Disable linkage
	pParser->SetLinkage( false );
	int32_t i = pParser->process();
	fin.close();
	return i;
}
开发者ID:hak,项目名称:criscript,代码行数:8,代码来源:cscl.cpp

示例11: tidyUp

void tidyUp(vector< vector<int> >& adj, stack<int>& results) {
  // Close file
  input.close();
  // Clear Stack
  while(!results.empty()) { results.pop(); }
  // Empty adjacency matrix
  adj.clear();
}
开发者ID:pevargas,项目名称:Algorithms,代码行数:8,代码来源:pvargas-assign2.cpp

示例12: testErrorCounter

int CounterErrorTester::testErrorCounter(ifstream& aInStream, CounterError& bProcessor, const char* cFilename)
{
	aInStream.open(cFilename);		//открываем файл
	cin.rdbuf(aInStream.rdbuf());		//получаем буфер
	int result = bProcessor.CountErorrs();  //вызываем счетчик ошибок
	aInStream.close();			//закрываем файл
	return result;				//отправляем результат
}						
开发者ID:5821gkv,项目名称:lipo-sapr-lab2,代码行数:8,代码来源:CounterErrorTester.cpp

示例13: fail

void fail()
{
    out << "0\n";
    in.close();
    out.close();

    exit(0);
}
开发者ID:slava-sh,项目名称:code-plagiarism-detector,代码行数:8,代码来源:413-a-3.cpp

示例14: closeFile

  /* 關閉檔案函式
   * FIXME:應改用較安全的String來當作filename*/
  short closeFile(const char filename[], ifstream& input_file)
  {
    /* FIXME:目前沒有檢查關閉檔案是否成功*/
    input_file.close();

    /*success*/
    return 0;
  }
开发者ID:Vdragon,项目名称:NTOU_CPP_HW_Opensource_Project,代码行数:10,代码来源:Operate_file_CPP.cpp

示例15: linestream

Gradebook::Course::Course(Gradebook& gb, ifstream& file, const string& courseName, const int& year, const Semester& semester)
	:m_gb(gb), m_courseName(courseName), m_year(year), m_semester(semester)
{
	string line;
	while (getline(file, line)) // each line of the CSV
	{
		m_students.push_back(Student()); // add a student to the course
		stringstream linestream(line);
		while (!linestream.eof()) {
			string record; // one comma-separated element
			while(linestream.peek()==' ') linestream.get(); // remove space after comma
			if(linestream.peek() == '"') // if the record is surrounded by quotes
			{
				linestream.get();
				getline(linestream, record, '"');
				while(linestream.peek() == '"') { // handle inner double quotes
					record += linestream.get();
					string piece;
					getline(linestream, piece, '"');
					record += piece;
				}
				if(linestream.peek()==',') linestream.get();
			}
			else
			{
				getline(linestream, record, ',');
			}
			m_students.back().push_back(record);
		}
	}
	file.close();

	// Move first element to m_fields
	m_fields = *m_students.begin();
	m_students.erase(m_students.begin());



	//takes the user IDs for every students and adds to a set of all students in the gradebook for easy counting with no duplicates
	int counter = 0; //for finding the user ID index
	for (Student::const_iterator field = m_fields.begin(); field != m_fields.end(); ++field) {
		string fval = *field; //current header title
		std:transform(fval.begin(), fval.end(), fval.begin(), ::tolower); //makes fval lower case for more accurate checking

		//finding the user id field
		if (fval.find("student id") != string::npos || fval.find("user id") != string::npos) break; //stop when we hit the id field
		else counter++; //stop when we find user id header
	}
	//add user IDs for all students to the set of student IDs
	int studentCount = 0;
	for (vector< Student >::const_iterator student = m_students.begin(); student != m_students.end(); ++student) {
		studentCount++;
		Student s = *student;
		gb.student_set.insert(s[counter]);
	}
	cout << "\nData read for " << studentCount << " students." << endl;

}
开发者ID:maribelCS,项目名称:gradesDataIntegration,代码行数:58,代码来源:Gradebook.cpp


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