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


C++ fstream::getline方法代码示例

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


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

示例1: Conf_Process

bool Conf_Process(std::fstream & f)
{
	char line[MAX_LINE_LENGTH];
	unsigned l = 0;
	bool breakflag = false;
	
	while (!f.eof() && !breakflag) {
		l++;
		f.getline(line, sizeof(line));
		if (line[0] == '\0') {
			// empty line, skip it (yeah we should ignore whitespaces too)
			continue;
		}
		if (line[0] == '/' && line[1] == '/') {
			// comment, skip it
			continue;
		}

		Conf_AcceptCommand(line, breakflag);
	}

	if (breakflag) {
		printf("Line: %u\n", l);
	}

	return true;
}
开发者ID:johnnycz,项目名称:qwscores,代码行数:27,代码来源:conf.cpp

示例2: LoadLuaTable

int LuaHistoryFile::LoadLuaTable(lua_State* luaState, size_t nBufferLen, std::fstream& fileStream)
{
	char* szRead = new char[4 * nBufferLen];
	lua_newtable(luaState);
	if(fileStream.getline(szRead, 4 * nBufferLen))
	{
		int nStrCnt = atoi(szRead);
		for(int ix = 1; ix <= nStrCnt; ++ix)
		{
			if(fileStream.getline(szRead, 4 * nBufferLen))
			{
				string strRead;
				wstring wstrRead;
				ANSI_to_Unicode(szRead, strlen(szRead), wstrRead);
				Unicode_to_UTF8(wstrRead.c_str(), wstrRead.size(), strRead);
				lua_pushstring(luaState, strRead.c_str());
				lua_rawseti(luaState, -2, ix);
			}
		}
	}
	delete []szRead;
	return 1;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:23,代码来源:HistroyFile.cpp

示例3: parseVC

void parseVC( std::fstream &file, std::string array_name, unsigned long int **array, char *chars,
		const unsigned int s, const unsigned long int P, const char skip=1 ) {
	std::string line;
	unsigned long int uli;
	std::cout << "Will read " << array_name << std::endl;
	if( skip )
		file.getline( chars, 500 ); //go past EOL
	if( file.peek() != '%' ) {
		std::cout << "Not at header line!" << std::endl;
		file >> line;
		std::cout << line << std::endl;
		file >> line;
		std::cout << line << std::endl;
		exit( 1 );
	}
开发者ID:ryancoleman,项目名称:lotsofcoresbook1code,代码行数:15,代码来源:McShared.cpp

示例4: leerLinea

void Agente::leerLinea(std::fstream& archivo, std::string& linea) {
	linea.clear();

	char buffer[T_BUFFER];

	bool seguirLeyendo = true;
	do {
		archivo.getline(buffer, T_BUFFER, '\n');
		linea.append(buffer, archivo.gcount());

		seguirLeyendo = (archivo.gcount() == T_BUFFER);

		if (archivo.bad())
			archivo.clear();

	} while (seguirLeyendo);
}
开发者ID:SebastianBogado,项目名称:fiuba-7542-tp-final,代码行数:17,代码来源:Agente.cpp

示例5: calculateTransform

void calculateTransform(std::fstream &pointsFs) {
    Eigen::Matrix4f trans;
    pcl::PointCloud<pcl::PointXYZ> points_in_kinect;
    pcl::PointCloud<pcl::PointXYZ> points_in_arm;

    //read data from file into data structures
    char temp_buf[200];
    pcl::PointXYZ KinPos;
    pcl::PointXYZ ArmPos;
    while(true){
        pointsFs.getline(temp_buf,200);
        if(pointsFs.eof()) break;
        if (sscanf(temp_buf,"%f,%f,%f,%f,%f,%f", &(KinPos.x), 
                   &(KinPos.y), &(KinPos.z), &(ArmPos.x), &(ArmPos.y), 
                   &(ArmPos.z)) == 6) {
            points_in_kinect.push_back(KinPos);
            points_in_arm.push_back(ArmPos);
        }
    }

    //calibrate
    pcl::registration::TransformationEstimationSVD<pcl::PointXYZ,pcl::PointXYZ> transformation_estimator;
    if(points_in_kinect.size() > 6 ) {
        transformation_estimator.estimateRigidTransformation(points_in_kinect,points_in_arm,trans);
        cout << "Calculated transformation: " <<endl;
        cout << trans << endl;
        //write to file
        std::ofstream fs("mat.txt");
        if(!fs){
            std::cerr<<"Cannot open the output file."<<std::endl;
        }
        else{
            fs<< trans << endl ;
            fs.close();
        }
        cout << "transformation matrix written to mat.txt " << endl;
    }
    else{
        cout << "Not enough points to run SVD estimation" << endl;
    }
}
开发者ID:CARRTUSF,项目名称:baxter_kinect_calibration,代码行数:41,代码来源:main.cpp

示例6: createandprintlist

//options
void createandprintlist()//option1
{
    
    
    
    char x[80];
    
    
    while (((s[0])>'9' || (s[0])<'0') && !f1.eof())
    {
        f1.getline(s, 80, ' ');
        l1.insertqueue(x);
        
       
    }
    
    
    l1.display();
    


}
开发者ID:codeOfRobin,项目名称:Linked-lists,代码行数:23,代码来源:main.cpp

示例7: main

int main()
{
    
    f1.open("/Users/robinmalhotra2/Desktop/csl201check.txt",std::ios::in|std::ios::out);
    
    f1.getline(s, 80, ' ');
        while (f1.good())
    {

        
        
        
       
        std::cout<<"addasd";
        if ((strlen(s)==1) && (s[0])<'9' && (s[0])>'0')
            
        {
            switch ((s[0]))
            {
                    
                case '1':
                    createandprintlist();
                    
                
                    break;
                    
                case '2':
                    sortlist();
                    break;
                    
                case '3':
                    nextinsert();
                    break;
                    
                case '4':
                    searchlist();
                    break;
                    
                case '5':
                    deletenext();
                    break;
                    
                case '6':
                    deduplicate();
                    break;
                    
                case '7':
                    mergesortthing();
                    break;
                    
                case '8':
                    credits();
                    break;
                    
                    
                    
                default:
                    break;
            }
        }
        
        
    }
    f1.close();
    
    
    
}
开发者ID:codeOfRobin,项目名称:Linked-lists,代码行数:68,代码来源:main.cpp


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