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);
4 replies to this topic
#1
Posted 01 April 2010 - 03:23 PM
|
|
|
#2
Posted 01 April 2010 - 03:34 PM
post more code
post function prototype
post the error message(s)
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
Posted 01 April 2010 - 03:42 PM
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
Posted 01 April 2010 - 03:58 PM
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.
#5
Posted 01 April 2010 - 04:02 PM
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


Sign In
Create Account


Back to top









