
-----------------------------------
cyberguy
Fri Jan 08, 2010 7:29 pm

Why is my function shortage not working?
-----------------------------------
[code]

# include 
# include 
# include 
# include 
#include 
# include 


using namespace std;

// Declare Global Variable

struct node {
        int Prod_Id ;
        char Prod_Name [20];
        char Prod_Category [10];
        char Prod_Supplier [20];
        float Prod_WholeSalePrice  ;   
        float Prod_RetailSalePrice ;
        float Prod_CostPrice;
        int Prod_stockcount;
        int order;
        node *next;// Pointer to next node
} product;



node *start_ptr = NULL;
node *temp1, *temp2;
node *current;

int rec_num ;


//###########################################
void addproduct () {
     
     string tempValue;
     bool ok;
     ofstream PRODUCT ("PRODUCT.txt", ios::app|ios::out);
         
     

                                  //data to be added to file
                                  //record number
         temp1 = new node;
         cout Prod_Name, tempValue.c_str());
	   PRODUCT Prod_Name 10){
			 ok=false;
			 cout Prod_Category, tempValue.c_str());
	   PRODUCT Prod_Category20){
			 ok=false;
			 cout Prod_Supplier, tempValue.c_str());
	  PRODUCT Prod_Supplier tempValue;
           temp1->Prod_WholeSalePrice = atof(tempValue.c_str());
           if (temp1->Prod_WholeSalePrice = atof(tempValue.c_str())){
              ok=true;}
           else{
                ok=false;
                cout Prod_RetailSalePrice = atof(tempValue.c_str());
           if (temp1->Prod_RetailSalePrice = atof(tempValue.c_str())){
              ok=true;}
           else{
                ok=false;
                cout Prod_stockcount = atoi(tempValue.c_str());
           if (temp1->Prod_stockcount = atoi(tempValue.c_str())){
              ok=true;}
           else{
                ok=false;
                cout order = atoi(tempValue.c_str());
           if (temp1->order = atoi(tempValue.c_str())){
              ok=true;}
           else{
                ok=false;
                cout Prod_CostPrice = atof(tempValue.c_str());
           if (temp1->Prod_CostPrice = atof(tempValue.c_str())){
              ok=true;}
           else{
                ok=false;
                cout next != NULL){  
               temp2 = temp2->next;//move to next link in chain    
         }
         temp2->next = temp1;
   }
    


}//end addpRODUCT
//*************************************************************
void read (){
     
     ifstream PRODUCT ("PRODUCT.txt");
     if (PRODUCT.is_open()){
                            

    PRODUCT.seekg(0,ios::end);
    size_t size = PRODUCT.tellg();
    if( size == 0)
    {
         cout Prod_Id;
                          PRODUCT >> temp1->Prod_Name;
                          PRODUCT >> temp1->Prod_Category;
                          PRODUCT >> temp1->Prod_Supplier;
                          PRODUCT >> temp1->Prod_WholeSalePrice;
                          PRODUCT >> temp1->Prod_RetailSalePrice;
                          PRODUCT >> temp1->Prod_stockcount;
                          PRODUCT >> temp1->order;
                          PRODUCT >> temp1->Prod_CostPrice;
                          
                          temp1->next = NULL;
              
          
                          //set up link to this node
                          if (start_ptr == NULL)
                          start_ptr = temp1;
                          else { 
                          temp2 = start_ptr;
                          //we know this is not NULL - list not empty!
                          while (temp2->next != NULL){  
                          temp2 = temp2->next;//move to next link in chain    
                          }
                          
             temp2->next = temp1;
             }
             
}while (!PRODUCT.eof() );
}
} 
 else cout next;
             }
          delete temp1;
          temp2->next = NULL;
        rec_num--;}
   }
cout > target;
     found = false;
     current = start_ptr;
     if (current == NULL)
          cout  next; 

This needs to be outside the "if" statement.

Thanks for explaining a bit more. It can really help to know when and how the program goes wrong.
