예제 #1
0
파일: PPMFile.cpp 프로젝트: Micp95/MTI_
int PPMFile::LoadHeader(fstream& file) {
	string tmp;

	//Wczytanie 1 linijki - system zapisu
	getline(file, tmp);
	if (tmp != "P6") {
		err = 2;
		return -1;
	}

	//Wczytanie 2 linijki - komentarz/rozmiar
	getline(file, tmp);
	if ( tmp[0] == '#')		//jeœli '#' to linijka jest komentarzem, jesli nie to danymi
		getline(file, tmp);

	//Rozdzielenie szerokosci i wysokosci obrazu
	stringstream strum(tmp);
	strum >> width;
	strum >> high;

	//Wczytanie maxa
	getline(file, tmp);
	strum = stringstream(tmp);
	strum >> max;

	//Zwrot rozmiaru naglowka
	int leng = file.tellp();
	return leng;
}
void student::pack(int mode)
{
	char *buffer= new char[maxlen*2];
	int disp;
	strcpy(buffer,usn);
	strcat(buffer,"|");
	strcat(buffer,name);
	strcat(buffer,"|");
	strcat(buffer,sem);
	strcat(buffer,"|");
	strcat(buffer,dept);
	strcat(buffer,"\n");
	
	if(!mode)
	{
		f.open(file, ios::out|ios::app);
		f.seekp(0,ios::end);
		disp = f.tellp();
	}
	f<<buffer;
	f.close();
	
	if(!mode)
	{
		pdx.open(pindex,ios::out|ios::app);
		pdx<<usn<<"\t"<<disp<<endl;
		pdx.close();
	
		sdx.open(sindex,ios::out|ios::app);
		sdx<<name<<"\t"<<usn<<endl;
		sdx.close();
	}
}
예제 #3
0
파일: lab2.cpp 프로젝트: Ashwini-D/fslab
   int search(string key)
   {
	   int pos,flag=0;
	   	f1.open("file.txt",ios::in);
	   	while(!f1.eof())
	   	{

	   		pos=f1.tellp();
	   		unpack();
	   		if(usn==key)
	   		{
	   			flag=1;
	   			return pos;
	   		}
	   	    if(flag==0)
	   		cout<<"not there";
	   	}
	   	return flag;
   }
예제 #4
0
파일: fslab.cpp 프로젝트: Ashwini-D/fslab
   void search(string key)
   {       
	        int flag=0;
	   	f1.open("file.txt",ios::in);
                 while(!f1.eof())
	   	{
                        getline(f1,buffer);
	   		pos=f1.tellp();
                        unpack();
	   		if(usn==key)
	   		{
	   			flag=1;
	   			cout<<"search successfull\n"<<pos;
                                
	   		}
                }
	   	    if(flag==0)
	   		cout<<"unsuccessfull search";
	   	
	   	
   }
예제 #5
0
파일: lab2.cpp 프로젝트: shilpakamath/fslab
int student::search(string key)
{

		int flag=0,pos;
		f1.open("data.txt",ios::in);
		while(!f1.eof())
		{
			getline(f1,buffer);

			unpack();
			if(key==usn)
			{
				cout<<"Record Found"<<endl;
				pos=f1.tellp();
				cout<<"Buffer is "<<buffer<<endl;
				f1.close();
				return pos;
			}
						
		}
		cout<<"Record not found"<<endl;
		f1.close();
}