Jump to content

Figure this out

- - - - -

  • Please log in to reply
4 replies to this topic

#1
hbk

hbk

    Learning Programmer

  • Members
  • PipPipPip
  • 71 posts
I am passing three structure character variables to the function below but it seems to be giving me a little problem.

I am using dev C++ compiler.

update(info.regis,info.treatment,info.app);

#2
Ancient Dragon

Ancient Dragon

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 400 posts
post more code
post function prototype
post the error message(s)
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.

#3
hbk

hbk

    Learning Programmer

  • Members
  • PipPipPip
  • 71 posts
This how my code is presently constructed

void update(char * ,char * ,char *);

void update(char * record1,char *record2,char *record3)
{
     
  system("color 2"); 
  
   
  int tell=0;
  int Found=0;
  long int offset = -1;
  char treat[30];
  char app[30];
     
              //Selection structure  to open a text file in reading mode and test if it exits
              if((customer1=fopen("customer1.txt","r+"))==NULL)
                   printf("THE FILE IS EMPTY");
              else
              {
                  //String copy function for storing two of the parameters in the appropriate variables
                  strcpy(treat,record2);
                  strcpy(app,record3);
                   
                  //While function to scan the file until it has reached the end and a logical operator               
                  while( !feof(customer1)&& Found==0)
                      {                                              
                        
                        //Fuction Call to ftell to detect present location in file                                                        
                        offset = ftell(customer1);                        
                        
                        //Scan file data into structure
                        fscanf(customer1,"%s %s %s %s %s %s %s %s\n",info.regis,info.Name,info.address,info.number,info.dob,info.treatment,info.allergies,info.app);
               
                        //Selection structure to use string compare to test for equality
                        if(strcmp(record1,info.regis)==0)
                        Found=1;
                      }
                     
                     //Selection structure
                      if(Found)
                      {                                                  
                        
                         //Function Call to fseek to find a particular postion in the opened file                                            
                        fseek(customer1,offset,SEEK_SET);                                     
                        
                        //Prints updated information to file                    
                        fprintf(customer1,"%s %s %s %s %s %s %s %s ",info.regis,info.Name,info.address,info.number,info.dob,treat,info.allergies,app);
                                       
                       }
                        else 
                        if(!Found)//Selection structure
                         printf("\n\n\t\t THERES NO SUCH RECORD");
                }    
        
     
     //Closes opened file
      fclose(customer1);             
     
                       
}


#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
If we can't compile the code, we can't really tell you what the issue is. You haven't listed the info about your struct. We need enough code that we can compile it into an executable.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
Ancient Dragon

Ancient Dragon

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 400 posts
And post the error messages.
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users