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


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

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


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

示例1: main

  int main(int argc, char *argv[])
  {
    printf("Starting\n");
	
    

    double dens=atof(argv[3]);
    int offset=atoi(argv[4]);
    printf("infile:%s\noutfile:%s\n\nDensity:%f\nofffset:%d\n",argv[1],argv[2],dens,offset);

    inFile.open(argv[1]);
    
    if (!inFile) {
        printf("Unable to open file");
        return 0; // terminate with error
    }
    else {
	printf("file loaded successfull\r\n");
    }
    
    ofstream outfile (argv[2]);
    //ofstream velfile ("vel.out");
    stringstream part2 (stringstream::in | stringstream::out);
   
    if (!outfile.is_open()) {
	printf("could not open outfile");
	return 0;
    }

   char line[512]; //increase to get more chars !

   double pos[3];
   pos[0]=pos[1]=pos[2]=0;
   double velx,vely,velz,omx,omy,omz=0;

   double D=0;
   double mass=0;
   float xlo,xhi,ylo,yhi,zlo,zhi;
   float ts=0;
   int atoms=0;
   int l = sizeof(line);

   inFile.getline(line,sizeof(line)); //z1=ITEM: TIMESTEP
   inFile.getline(line,sizeof(line)); //z2=1000
	ts=atof(line);
	cout<<"timestep:"<<ts<<endl;
   //inFile.getline(line,sizeof(line)); //z3=ITEM: LABEL
   //inFile.getline(line,sizeof(line)); //z4=rem_0.6_0.2_0_1e-06
   inFile.getline(line,sizeof(line)); //z5=ITEM: NUMBER OF ATOMS
   inFile.getline(line,sizeof(line)); //z6={N}
	atoms=atoi(line);
	cout<<"Atoms:"<<atoms<<endl;
   inFile.getline(line,sizeof(line)); //z7
   inFile.getline(line,sizeof(line)); //z8

	for (int i = 0; i < l; i++)
    		{
        		if (line[i] == ' ')
        		{
            		line[i] = '\0';
            	}
    	}    
        char* startp = line;
	xlo=atof(startp);
	startp += strlen(startp) + 1;
	xhi=atof(startp);
   
	inFile.getline(line,sizeof(line)); //z7
	for (int i = 0; i < l; i++)
    		{
        		if (line[i] == ' ')
        		{
            		line[i] = '\0';
            	}
    	}    
        startp = line;
	ylo=atof(startp);
	startp += strlen(startp) + 1;
	yhi=atof(startp);
   
	inFile.getline(line,sizeof(line)); //z8
	for (int i = 0; i < l; i++)
    		{
        		if (line[i] == ' ')
        		{
            		line[i] = '\0';
            	}
    	}    
        startp = line;
	zlo=atof(startp);
	startp += strlen(startp) + 1;
	zhi=atof(startp);
	

   inFile.getline(line,sizeof(line)); //z9
	cout<<"Line:"<<line<<endl; //header
   double d=0;

   int lc=0;
   int ac=offset;
//.........这里部分代码省略.........
开发者ID:richti83,项目名称:LIGGGHTS-WITH-BONDS,代码行数:101,代码来源:dump2read.cpp

示例2: readOperatorList

bool MlOperatorList::readOperatorList(ifstream& ifs)
{
	char buffer[1024];
	while (ifs.good() && ifs.getline(buffer,1024))
		if (ifs.gcount()>0 && buffer[0] != '#')
			break;

	size_t n=0;
	if (sscanf(buffer,"%d",&n) != 1)
		error("expected line with number of operaotrs");

	executionOrder_.clear();
	executionOrder_.reserve(n);
	drops_.clear();
	indicators_.clear();
	normalizations_.clear();
	functions_.clear();
	splits_.clear();
	conditionals_.clear();

	for (size_t i=0; i<n; i++)
	{
		if (! ifs.good())
			return false;

		ifs.getline(buffer,1024);
		if (ifs.gcount()<=0)
			return false;

		istringstream iss(buffer);

		char type=' ';
		iss >> type;
		switch (type) {
			case 'D':
				{
					size_t dropIdx=0;
					iss >> dropIdx;
					if (iss.fail())
						error("Error reading line:",buffer);

					executionOrder_.push_back(IdxPair(OT_DROP,drops_.size()));
					drops_.push_back(dropIdx);
				}
				break;

			case 'I':
				{
					IndicatorOperator iop;
					iss >> iop.sourceIdx >> iop.targetIdx;
					if (iss.fail())
						error("Error reading line:",buffer);
					executionOrder_.push_back(IdxPair(OT_INDICATOR,indicators_.size()));
					indicators_.push_back(iop);
					break;
				}

			case 'F':
				{
					FunctionOperator fop;
					iss >> fop.sourceIdx >> fop.targetIdx;
					string typeStr;
					iss >> typeStr;
					size_t i;
					for (i=0; i<numConditionalValueLabels; i++)
						if (! strcmp(typeStr.c_str(),conditionalValueLabels[i]))
							break;
					if (i == numConditionalValueLabels)
						error("Error reading line:",buffer);
					fop.type = i;
					executionOrder_.push_back(IdxPair(OT_FUNCTION,functions_.size()));
					functions_.push_back(fop);
				}

			case 'N':
				{
					NormalizationOperator nop;
					iss >> nop.sourceIdx >> nop.targetIdx >> nop.mu >> nop.sigma;
					if (iss.fail())
						error("Error reading line:",buffer);
					executionOrder_.push_back(IdxPair(OT_NORMALIZATION,normalizations_.size()));
					normalizations_.push_back(nop);
				}
				break;

			case 'S':
				{
					SplitOperator sop;
					iss >> sop.sourceIdx;

					size_t n;
					iss >> n;
					if (iss.fail())
						error("Error reading line:",buffer);
					sop.thresholds.resize(n);
					sop.indexesForBinValues.resize(n+1);
					sop.indexesForBinIndicators.resize(n+1);
					for (size_t i=0; i<n; i++)
						iss >> sop.thresholds[i];
					for (size_t i=0; i<=n; i++)
//.........这里部分代码省略.........
开发者ID:benpullman,项目名称:mscluster2,代码行数:101,代码来源:mloperatorlist.cpp

示例3: bIsModeMismatch

BOOL bIsModeMismatch( ifstream& omInReplayFile,
                      BOOL bReplayHexON,
                      WORD wLogReplayTimeMode)
{
    BOOL bFlag = FALSE;
    BOOL bLine = TRUE;
    CHAR Line[500] = { NULL };
    CString omStrLine;
    BOOL bLogModeChecked = FALSE;
    BOOL bReplayMsgTypeChecked = FALSE;
    if(omInReplayFile != NULL)
    {
        while( bLine &&  ! omInReplayFile.eof())
        {

            omInReplayFile.getline( Line, sizeof(Line));
            omStrLine = Line;

            if( omStrLine.Find(HEX_MODE) == 0)
            {
                bLogModeChecked = TRUE;

                if(bReplayHexON != TRUE)
                {
                    bFlag = TRUE;
                }
            }
            else if (omStrLine.Find(DEC_MODE) == 0)
            {
                bLogModeChecked = TRUE;

                if(bReplayHexON != FALSE)
                {
                    bFlag = TRUE;
                }
            }
            if( omStrLine.Find(SYSTEM_MODE) == 0)
            {
                bReplayMsgTypeChecked = TRUE;
                if( wLogReplayTimeMode != eSYSTEM_MODE)
                {
                    bFlag = TRUE;
                    bLine = FALSE;
                }
            }
            else if( omStrLine.Find(ABSOLUTE_MODE) == 0)
            {
                bReplayMsgTypeChecked = TRUE;
                if( wLogReplayTimeMode != eABSOLUTE_MODE)
                {
                    bFlag = TRUE;
                    bLine = FALSE;
                }
            }
            else if( omStrLine.Find(RELATIVE_MODE) == 0)
            {
                bReplayMsgTypeChecked = TRUE;
                if( wLogReplayTimeMode != eRELATIVE_MODE)
                {
                    bFlag = TRUE;
                    bLine = FALSE;
                }
            }
            if(bLogModeChecked == TRUE && bReplayMsgTypeChecked == TRUE)
            {
                bLine = FALSE;
            }
        }
    }
    return bFlag;
}
开发者ID:ArunMaiya,项目名称:busmaster,代码行数:71,代码来源:Utility_Replay.cpp

示例4: getData

void getData(){

	char line[500];
	string s;
	pair<long long, long long> pr;
	long long timestamp, user, item, rating;

	//getting the user-item-rating matrix
	fin.open("dataset/ua.base.txt");
	while(!fin.eof()){
		fin>>user;
		fin>>item;
		fin>>rating;
		fin>>timestamp;
		inputMatrix[user][item] = rating;
		pr = make_pair(item, rating);
		ratings[user].push_back(pr);
		dummy[item]++;	
	}
	fin.close();
	for(int i=0; i<2000; i++) mostRated.push_back(make_pair( dummy[i], i ));	
	//cout<<"Matrix built\n";

	/*cout<<"No of users = "<<ratings.size()<<endl;
	for(int i=0; i<5; i++){
		cout<<"User "<<i<<endl;
		for(int j=0; j<ratings[i].size(); j++){
			cout<<"\t"<<"item= "<<ratings[i][j].first<<", rating = "<<ratings[i][j].second;
		}
	}*/

	//getting the item-itemName mapping
	fin.open("dataset/u.item.txt");
	while(fin.getline(line, 500)){
		stringstream ss(line);
		getline(ss, s, '|');
		char str[100];
		for(int i=0; s[i]!='\0'; i++) str[i] = s[i];
		item = atoi(str);
		getline(ss, s, '|');
		itemDetails[item] = s;
		//Skipping over other values as not using them
	}
	fin.close();

	/*cout<<"No of items="<<itemDetails.size();
	for(int i=0; i<15; i++)
		cout<<i<<":"<<itemDetails[i]<<endl;*/

	//getting the top 30 user similarities
	fin.open("topNeighbours.txt");
	int user1, user2;
	float rat;
	while(!fin.eof()){
		fin>>user1;
		for(int i=0; i<300; i++){
			fin>>rat>>user2;
			if(user2<=1 || user2>944) continue;
			topNeighbours[user1].push_back(user2);
			userSimilarity[user1][user2] = rat;
		}
		cout<<user1<<" ";
	}
	fin.close();
	//cout<<"Similarity taken\n";

}
开发者ID:Devil399,项目名称:Recommendation-System,代码行数:67,代码来源:recommend.cpp

示例5: main

int main()
{
    int nr,i,n;
    char c;
    in.getline(s,1100);
    nr=-1;
    while(s[p])
    {
        if(s[p]==' ')
        {
            ++p;
            continue;
        }
        if(s[p]=='T' && s[p+1]=='R' && s[p+2]=='U' && s[p+3]=='E')
        {
            z[++nr]='1';
            p+=4;
            continue;
        }
        if(s[p]=='F' && s[p+1]=='A' && s[p+2]=='L' && s[p+3]=='S' && s[p+4]=='E')
        {
            z[++nr]='0';
            p+=5;
            continue;
        }
        if(s[p]=='(' || s[p]==')')
        {
            z[++nr]=s[p];
            ++p;
            continue;
        }
        if(s[p]=='A' && s[p+1]=='N' && s[p+2]=='D')
        {
            z[++nr]='&';
            p+=3;
            continue;
        }
        if(s[p]=='N' && s[p+1]=='O' && s[p+2]=='T')
        {
            z[++nr]='~';
            p+=3;
            continue;
        }
        if(s[p]=='O' && s[p+1]=='R')
        {
            z[++nr]='|';
            p+=2;
            continue;
        }
        if(s[p]>='A' && s[p]<='Z')
        {
            z[++nr]=s[p]-'A'+'a';
            p++;
            continue;
        }
    }
    //for(i=0;z[i];++i)
     //   out<<z[i];
    p=0;
    in>>n;
    in.getline(s,1000);
    for(i=1;i<=n;++i)
    {
        p=0;
        in>>c;
        v[c-'A']=(v[c-'A']+1)%2;
        out<<expresie();
    }
    return 0;
}
开发者ID:rusucosmin,项目名称:cplusplus,代码行数:70,代码来源:main.cpp

示例6: ReadlnString

void ReadlnString(ifstream& f, CString& s)
{
	char buf[256];
	f.getline(buf,255,'\n');
	s = buf;
}
开发者ID:hksonngan,项目名称:mytesgnikrow,代码行数:6,代码来源:Global.cpp

示例7: if

CurveToken
avtCurve2DFileFormat::GetPoint(ifstream &ifile, double &x, double &y, string &ln)
{
    char line[256];
    ifile.getline(line, 256, '\n');

    // Do an ASCII check.  We only support text files.
    if (GetStrictMode() && !StringHelpers::IsPureASCII(line,256))
        EXCEPTION2(InvalidFilesException, filename, "Not ASCII.");

    //
    // Parenthesis are special characters for variables names, etc, so just
    // change them to square brackets to "go with the flow"...
    //
    size_t i, nchars = strlen(line);
    for (i = 0 ; i < nchars ; i++)
    {
        if (line[i] == '(')
            line[i] = '<';
        else if (line[i] == ')')
            line[i] = '>';
    }
    ln = line;

    //
    // Pick out some of the harder to parse cases.
    //
    if (strstr(line, "#") != NULL)
    {
        return HEADER;
    }
    bool allSpace = true;
    size_t len = strlen(line);
    for (i = 0 ; i < len ; i++)
    {
        if (!isspace(line[i]))
        {
            allSpace = false;
        }
    }
    if (allSpace)
    {
        return WHITESPACE;
    }
    if (strncmp(line, "end", strlen("end")) == 0)
    {
        // We will infer that we have hit the end when we find a new token.
        // Just treat this as white space to make our parsing rules easier.
        return WHITESPACE;
    }

    //
    // We are assuming that we a number.  Fortran-style scientific notation
    // uses 'D' when we are used to seeing 'E'.  So just switch them out.
    //
    for (i = 0 ; i < len ; i++)
    {
        if (line[i] == 'D' || line[i] == 'd')
            line[i] = 'E';
        if (line[i] == '\t')
            line[i] = ' ';
    }

    char *ystr = NULL;

    errno = 0;
    x = strtod(line, &ystr);
    if (((x == 0.0) && (ystr == line)) || (errno == ERANGE))
    {
        return INVALID_POINT;
    }
    if (ystr == NULL)
    {
        return VALID_XVALUE;
    }
    ystr = strstr(ystr, " ");
    if (ystr == NULL || ystr == line)
    {
        return VALID_XVALUE;
    }
    
    // Get past the space.
    ystr++;

    char *tmpstr;
    errno = 0;
    y = strtod(ystr, &tmpstr);
    if (((y == 0.0) && (tmpstr == ystr)) || (errno == ERANGE))
    {
        return INVALID_POINT;
    }

    ln = "";
    return VALID_POINT;
}    
开发者ID:burlen,项目名称:visit_vtk_7_src,代码行数:95,代码来源:avtCurve2DFileFormat.C

示例8: while

/************************************************************************
*									*
*  Load ROI polygon.  File format is described in "save" routine.
*  The name line in the file ("polygon") has already been read by the
*  routine that calls this one.
*									*/
void
Polygon::load(ifstream &infile)
{
    const int buflen=128;
    char buf[buflen];
    int ndata=0;
    int isclosed;
    Fpoint *temp;

    // Read the number of points to expect
    while ( infile.getline(buf, buflen) ){
	if (buf[0] == '#'){
	    continue;
	}else if (strspn(buf, "\t ") == strlen(buf)){	// Ignore blank lines
	    continue;
	}else{
	    if (sscanf(buf,"%d", &ndata) != 1){
		msgerr_print("ROI polygon: Missing number of vertices");
		return;
	    }else{
		break;
	    }
	}
    }
    if (ndata < 3){
	msgerr_print("ROI polygon. Number vertices must be at least 3");
	return;
    }
    temp = new Fpoint[ndata];

    // Read in the data
    int i = 0;
    while ((i != ndata) && infile.getline(buf, buflen)){
	if (buf[0] == '#'){
	    continue;
	}else if (strspn(buf, "\t ") == strlen(buf)){	// Ignore blank lines
	    continue;
	}else{
	    if (sscanf(buf,"%f %f", &(temp[i].x), &(temp[i].y)) != 2){
		msgerr_print("ROI polygon: Missing data input");
		return;
	    }
	    i++;
	}
    }

    if (ndata != i){
	msgerr_print("ROI polygon: Incomplete input data points");
	return;
    }

    // Check if polygon is closed
    if (temp[0].x == temp[ndata-1].x && temp[0].y == temp[ndata-1].y){
	ndata--;
	isclosed = TRUE;
    }else{
	isclosed = FALSE;
    }

    // Put new ROIs in the appropriate frames
    Gframe *gframe;
    Roitool *tool;
    i = 1;
    for (gframe=Frame_select::get_selected_frame(i);
	 gframe;
	 gframe = Frame_select::get_selected_frame(++i))
    {
	if (gframe->imginfo){
	    tool = new Polygon(ndata, temp, gframe, isclosed);
	    tool->select(ROI_NOREFRESH, TRUE);
	    //gframe->display_data();
	}
    }
    delete [] temp;
}
开发者ID:DanIverson,项目名称:OpenVnmrJ,代码行数:81,代码来源:polygon.c

示例9: open

void GrowWindow::open( ifstream& fp)
{
    int		type;
    int 		end_found = 0;
    char		dummy[40];
    int		tmp;

    for (;;)
    {
        if ( !fp.good()) {
            fp.clear();
            fp.getline( dummy, sizeof(dummy));
            printf( "** Read error GrowWindow: \"%d %s\"\n", type, dummy);
        }

        fp >> type;
        switch( type) {
        case glow_eSave_GrowWindow:
            break;
        case glow_eSave_GrowWindow_file_name:
            fp >> file_name;
            break;
        case glow_eSave_GrowWindow_scrollbar_width:
            fp >> scrollbar_width;
            break;
        case glow_eSave_GrowWindow_scrollbar_color:
            fp >> tmp;
            scrollbar_color = (glow_eDrawType)tmp;
            break;
        case glow_eSave_GrowWindow_scrollbar_bg_color:
            fp >> tmp;
            scrollbar_bg_color = (glow_eDrawType)tmp;
            break;
        case glow_eSave_GrowWindow_vertical_scrollbar:
            fp >> vertical_scrollbar;
            break;
        case glow_eSave_GrowWindow_horizontal_scrollbar:
            fp >> horizontal_scrollbar;
            break;
        case glow_eSave_GrowWindow_window_scale:
            fp >> window_scale;
            break;
        case glow_eSave_GrowWindow_owner:
            fp.get();
            fp.getline( owner, sizeof(owner));
            break;
        case glow_eSave_GrowWindow_rect_part:
            GrowRect::open( fp);
            break;
        case glow_eSave_GrowWindow_userdata_cb:
            if ( ctx->userdata_open_callback)
                (ctx->userdata_open_callback)(&fp, this, glow_eUserdataCbType_Node);
            break;
        case glow_eSave_End:
            end_found = 1;
            break;
        default:
            cout << "GrowWindow:open syntax error" << endl;
            fp.getline( dummy, sizeof(dummy));
        }
        if ( end_found)
            break;
    }

    if ( strcmp( file_name, "") != 0)
        new_ctx();
    configure_scrollbars();
}
开发者ID:Strongc,项目名称:proview,代码行数:68,代码来源:glow_growwindow.cpp

示例10: readAssoQua

bool readAssoQua(ifstream & fin, deque<dtdclass *>&d_class, char * name, associate & basAsso, associate& toAsso){
    char filedetail[256];/*record the each line of file from the compiler*/
    char * tempChar;
    string temp, qualiClass;
    bool finishQualiAssoClass = false;
    bool haveQualification = false;
    bool haveAssociation = false;/*check the association have detail or not*/
    attribute tempattribute;
    deque<attribute *> tempQualification;
    
    deque<dtdclass*>::iterator first;/*recond the first position of the deque*/
    deque<dtdclass*>::iterator last;/*recond the last position of the deque*/
    do{
        fin.getline(filedetail,255);
        if(strcmp(filedetail, "")==0){continue;}/*if the line is empty, continue*/
        tempChar = strtok(filedetail,"<>");//cut front of "<"
        tempChar = strtok(NULL, "<>");/*get the detail between <> */
        temp = tempChar;
        if(temp=="/association_class" || temp =="/Link"){//check if is end of one association class
            finishQualiAssoClass=true;//is control while loop
        }
        else if(temp == "nameOfAssociationClass"){
            haveAssociation=true;
            tempChar = strtok(NULL, "<>");
            strcpy(name, tempChar);
            qualiClass = tempChar;
            if(!d_class.empty()){//check the deque is not empty
                    first = d_class.begin();//get the begin of the deque
                    last = d_class.end();//get the end of the deque
                    for (deque<dtdclass *>::iterator i=first; i !=last;i++){
                        if(qualiClass ==(*i)->getname()){//add association into class
                            (*i)->setlevel(1);
                            int tempMulti;
                            tempMulti = basAsso.to_multi;
                            basAsso.to_multi = 1;/*change the multi link of the association*/
                            (*i)->setassociation(basAsso);//add association
                            basAsso.to_multi = tempMulti;;/*get back the original multi link number of the association*/
                            tempMulti = toAsso.to_multi;
                            toAsso.to_multi =1;/*change the multi link of the association*/
                            (*i)->setassociation(toAsso);//add association
                            toAsso.to_multi = tempMulti;/*get back the original multi link number of the association*/
                            if(haveQualification == true){
                                if(!tempQualification.empty()){/*get the qualification attribute from the deque and add it into the class*/
                                    deque<attribute *>::iterator firstAttribute = tempQualification.begin();
                                    deque<attribute *>::iterator lastAttribute =  tempQualification.end();
                                    for(deque<attribute * >::iterator attributeI = firstAttribute; attributeI != lastAttribute; attributeI++){
                                        strcpy(tempattribute.att_name, (*attributeI)->att_name);
                                        tempattribute.isId = (*attributeI)->isId;
                                        tempattribute.ismulti= (*attributeI)->ismulti;
                                        (*i)->setattribute(tempattribute);//add the attribute into the class
                                    }
                                }
                            }/*finish add all qualification into the class*/
                        }
                    }
                }
        }
        else if(temp == "qualification"){
            haveAssociation = true;
            tempChar = strtok(NULL, "/<");
            temp = tempChar;
            if(temp !="<"){
                attribute * tempAttri = new attribute;
                strcpy(tempAttri->att_name,tempChar);
                tempAttri->isId = true;
                tempAttri->ismulti = false;
                haveQualification =true;
                tempQualification.push_back(tempAttri);
            }
        }
        
    }while(finishQualiAssoClass !=true);
    return haveAssociation;
}
开发者ID:vitawebsitedesign,项目名称:321,代码行数:74,代码来源:main.cpp

示例11: deserialize

int Index::deserialize(ifstream& ifs, map<string, SNode>& metadata, const Address* addr)
{
   vector<string> dirs;
   dirs.resize(1024);
   map<string, SNode>* currdir = &metadata;
   int currlevel = 1;

   while (!ifs.eof())
   {
      char tmp[4096];
      tmp[4095] = 0;
      char* buf = tmp;

      ifs.getline(buf, 4096);
      int len = strlen(buf);
      if ((len <= 0) || (len >= 4095))
         continue;

      for (int i = 0; i < len; ++ i)
      {
         if (buf[i] == ' ')
         {
            buf[i] = '\0';
            break;
         }
      }

      int level = atoi(buf);

      SNode sn;
      sn.deserialize(buf + strlen(buf) + 1);
      if ((!sn.m_bIsDir) && (NULL != addr))
      {
         sn.m_sLocation.clear();
         sn.m_sLocation.insert(*addr);
      }

      if (level == currlevel)
      {
         (*currdir)[sn.m_strName] = sn;
         dirs[level] = sn.m_strName;
      }
      else if (level == currlevel + 1)
      {
         map<string, SNode>::iterator s = currdir->find(dirs[currlevel]);
         currdir = &(s->second.m_mDirectory);
         currlevel = level;

         (*currdir)[sn.m_strName] = sn;
         dirs[level] = sn.m_strName;
      }
      else if (level < currlevel)
      {
         currdir = &metadata;

         for (int i = 1; i < level; ++ i)
         {
            map<string, SNode>::iterator s = currdir->find(dirs[i]);
            currdir = &(s->second.m_mDirectory);
         }
         currlevel = level;

         (*currdir)[sn.m_strName] = sn;
         dirs[level] = sn.m_strName;
      }
   }

   return 0;
}
开发者ID:norouzi4d,项目名称:sector,代码行数:69,代码来源:index.cpp

示例12: readline

string readline(ifstream &f)
{
	char buf[1024];
	f.getline(buf, 1024);
	return buf;
}
开发者ID:AlexAlbala,项目名称:Alter-Native,代码行数:6,代码来源:assignment8.cpp

示例13: main

int main(int argv,char*argc[])
{
    int w,h;
    fin >> w >> h;
    vector<vector<char> > map;
    char tmp[200];
    fin.getline(tmp,200);
    for(int i=0;i<=2*h;++i)
    {
        vector<char> row;
        fin.getline(tmp,200);
        for(int j=0;j<=2*w;++j)
        {
            row.push_back(tmp[j]);
        }
        map.push_back(row);
    }
    int x,y;
    vector<int> node(w*h);
    vector< vector<int> > edge(w*h);
    vector<int> st;
    for(int i=0;i<=h;++i)
    {
        y=2*i;
        for(int j=0; j<w;++j)
        {
            x=2*j+1;
            if(map[y][x]==' ')
            {
                if(i==0)
                {
                    node[i*w+j] = 1;
                    st.push_back(i*w+j);
                }
                else if(i==h)
                {
                    node[(i-1)*w+j] = 1;
                    st.push_back(i*w-w+j);
                }
                else
                {
                    edge[i*w+j].push_back((i-1)*w+j);
                    edge[(i-1)*w+j].push_back(i*w+j);
                }
            }
        }
    }
    for(int i=0;i<h;++i)
    {
        y=2*i+1;
        for(int j=0;j<=w;++j)
        {
            x=2*j;
            if(map[y][x]==' ')
            {
                if(j==0)
                {
                    node[i*w+j] = 1;
                    st.push_back(i*w+j);
                }
                else if(j==w)
                {
                    node[i*w+j-1] = 1;
                    st.push_back(i*w+j-1);
                }
                else
                {
                    edge[i*w+j].push_back(i*w+j-1);
                    edge[i*w+j-1].push_back(i*w+j);
                }
            }
        }
    }
    int max=0;
    vector<int> vv[2];
    for(int ss=0;ss < 2;++ss)
    {
        int s=st[ss];
        vv[ss].resize(w*h);
        vector<int> abl(w*h);
        abl[s]=1;
        vv[ss][s] = 1;
        queue<pair<int,int> > que;
        que.push(make_pair(s,1));
        pair<int,int> top;
        int dist,num;
        while(!que.empty())
        {
            top = que.front();
            que.pop();
            num = top.first;
            dist = top.second;
            for(vector<int>::iterator it=edge[num].begin(); it != edge[num].end();++it)
            {
                if(abl[*it]==0)
                {
                    abl[*it]=1;
                    que.push(make_pair(*it,dist+1));
                    vv[ss][*it] = dist+1;
                }
//.........这里部分代码省略.........
开发者ID:GenguoWang,项目名称:usaco,代码行数:101,代码来源:maze1_1.cpp

示例14: BuscarValorEc

// Calcula y Retorna el entero de la formula (info)
int BuscarValorEc(ifstream&lectura, ofstream &fina,char*info,int hoja)
{
    info++;
    char *suma [70];
    char * ptr ;
    char * formula= new char [500];
    char * col = new char [200];
    char * fil;
    int fila,j,columnaa,val=0,sum[70];
    ptr = strtok(info,"+");
    int i=0;
    while(ptr != NULL)
    {
        suma[i] = ptr;
        ptr = strtok(NULL, "+");
        i++;
    }
    for(int m=0; m<i; m++)
    {
        posicion(lectura,hoja);
        lectura.getline(formula,200);
        j=0;
        fil=col= suma[m];
        while(58< *(fil) ||*(fil)< 47)
        {
            fil++;
        }
        while( *(fil+j)!= '\0')
        {
            *(formula+j)= *(fil+j);
            j++;
        }
        *(formula+j)='\0';
        *fil='\0';
        fil=formula;
        fila=numero(fil);
        columnaa=columna(col);
        for(int k=1; k<fila; k++)
        {
            lectura.getline(formula,200);
        }
        for(int p=1; p<columnaa; p++)
        {
            lectura>>formula;
        }
        lectura>>formula;
        if(*formula!='=')
        {
            sum[m]=numero(formula);
        }
        else
        {
            sum[m]=BuscarValorEc(lectura,fina,formula,hoja);
        }
    }
    for(int o=0; o<i; o++)
    {
        val =val +sum[o];
    }
    delete []suma;
    delete []formula;
    delete []col;
    delete []ptr ;
    return val;

}
开发者ID:kstro96,项目名称:Proyecto-Sustentacion-final,代码行数:67,代码来源:HojaDeCalculo.cpp

示例15: setData

//========================setData=====================================
// Sets this Object's description to the line of characters extracted
// from the infile stream. If the description is longer than 
// MAX_SIZE the trailing data will be omitted. 
// 
// Preconditions: The give ifstream is open. 
//		
// Postconditions: my_desc is set to the first MAX_SIZE of chars in 
//		   the infile.
//====================================================================
void Object::setData (ifstream &infile)
{
	if (infile.is_open()) 
		infile.getline (my_desc, MAX_SIZE + 1);	
}	
开发者ID:johnsteele,项目名称:dijkstra-graph,代码行数:15,代码来源:Object.cpp


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