Thread: Please help me with this !! Emergency

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    3

    Please help me with this !! Emergency

    I have this code
    Code:
    /*checking if the products in supplyfile correspond in real products*/
    void runF22(int N)
    {
    	int i=0,found, productnummax,productnum=0;
    	char line[1000],*f;
    	char Msg05[]="The product code doesn't exist";
    	struct Sys_Rec a;
    	struct Prod_Rec b, B[Prod_Items_max];
    	FILE *p_product, *p_sys;
    
    	/* we open sys.dat to find product max number*/
    	/* and products File name to open it*/
    	p_sys=fopen("sys.dat","r");
    	while(!feof(p_sys)){
    		fscanf(p_sys,"%d %d %s %d %s %d %d %s",&a.Sys_WhNum,
    	   &a.Sys_ProdNum,a.Sys_WhFN,&a.Sys_StorVol,a.Sys_ProdFN,
               &a.Sys_SupMaxItems,&a.Sys_OrdMaxItems,a.Sys_VolDescr);
    	}
    	productnummax=a.Sys_ProdNum;
    
    	f=a.Sys_ProdFN;
    	fclose(p_sys);
    	p_product=fopen(f,"r");
    
    	/* cheking if product file is empty*/
    	if(p_product==NULL){
    		printf("error reading product file");
    		exit(5);
    	}
    
    	/*open product file and create an array B to store objects*/
    	/* and find the number of product exists*/
    	while(fgets(line,998,p_product)){
    		int ret;
    		ret=sscanf(line,"%d %s %d %s", &b.Prod_Code,b.Prod_Descr,
    		&b.Prod_Vol,b.Prod_Storage_Option);
    
    		B[productnum]=b;               /*store in array B if line is Ok*/
    		productnum++;
    		if(productnum==productnummax) break;  /*don't read too many*/
    	}
    
    
    	/*checking if all items for import exist as product*/
    	i=0;found=0;
    	while(i<productnum && found==0){
    			if(B[i].Prod_Code==N)found=1;
    			i++;
    		}
    	if(found==0){
    		fprintf(stderr,Msg05); /*not real product for import*/
    	    exit(5);
    	}
    	else
    		return;   /*if the item exist to F21 to continue*/
    }
    CAN SOMENONE TELL ME A LIST OF CHARACTERISTICS THAT NEED TO BE CHECKED IF WE WANT TO CONTROL (CHECK) THAT THE CODE IS RIGHT ??

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. plz help me make my assigment more bulletproof
    By joker_tony in forum C Programming
    Replies: 4
    Last Post: 03-28-2008, 09:03 PM
  2. Emergency help for the problem !!!
    By chelp151 in forum C Programming
    Replies: 7
    Last Post: 04-22-2007, 12:09 PM
  3. Emergency
    By taha54 in forum C Programming
    Replies: 8
    Last Post: 03-17-2006, 08:10 AM
  4. Emergency 2
    By newuser21 in forum C Programming
    Replies: 3
    Last Post: 03-12-2006, 09:04 AM
  5. another novice need some emergency help
    By KarateKid in forum C++ Programming
    Replies: 1
    Last Post: 12-04-2001, 11:09 PM