Ejemplo n.º 1
0
// Read each item in turn.
void corrobj::read(char *parfile)
{

    read_par(parfile);
    kcorr = new kcorr_table(par.kcorr_file);
    read_primary();

    if (par.corrtype == 1 || par.corrtype == 3)
        read_secondary();
    else
        read_random_secondary();

    read_rev();

}
Ejemplo n.º 2
0
int main(int argc,char* argv[])
{
	if(argc!=3)
	{
		printf("ERROR\n");
		exit(-1);
	}
	else
	{
		if(strcmp(argv[1],"--first-fit")==0){
			listOrder=FIRSTFIT;
		} 
		else if(strcmp(argv[1],"--best-fit")==0){
			listOrder=BESTFIT;
		}
		else if(strcmp(argv[1],"--worst-fit")==0){
			listOrder=WORSTFIT;
		}

		fileName=argv[2];//filename of the student file
	}

	char *op,*mydata,*key,*temp,command[150];
	const char token2[3]=" \n";
	const char token1[2]=" ";

	if((fp=fopen(fileName,"r+b"))!=NULL){
		read_primary();
		read_availability();
	}

	while(1)
	{
		fgets(command,150,stdin);
		temp=strtok(command,token2);
		op=temp;

		if(strcmp(op,"add")==0){
			temp=strtok(NULL,token1);
			key=atoi(temp);
			temp=strtok(NULL,token1);
			mydata=temp;
			add(key,mydata);
		}
		else if(strcmp(op,"find")==0){
			temp=strtok(NULL,token1);
			key=atoi(temp);
			find(key);
		}
		else if(strcmp(op,"del")==0){
			temp=strtok(NULL,token1);
			key=atoi(temp);
			del(key);
		}
		else if(strcmp(op,"end")==0){
			break;
		}
		else{
			printf("Invalid Command\n");
		}
	}

	end();
}