#include
#include
Struct yonghu//user information
{
Char password [7];//the user password
Char name [7];//user name
Char id [20];//user id
} the users [500];
Void revise ();//modify information
Int main ()
{
Revise ();
return 0;
}
Void revise ()
{
int i;
Password2 char name2 [7], [7], id2 [20].
Char name3 [7].
Printf (" please input to modify the user name: \ n ");
The scanf (" % s ", name3);
Printf (" please enter the user name change: \ n ");
The scanf (" % s ", name2);
Printf (" please enter a password change: \ n ");
The scanf (" % s ", password2);
Printf (" please enter modify id: \ n ");
The scanf (" % s ", id2);
The FILE * fp.
Fp=fopen (" user information. TXT ", "a");
for(i=0; i<5; I++)
{
If (STRCMP (users [I]. Name, name3 [7])==0)
{
Fscanf (fp, "% s % s % s", the users [I]. Name, users [I] password, users [I] id);
Printf (" user name: % s \ n ", the users [I] name);
Printf (" password: % s \ n ", the users [I] password);
Printf (" id: % s \ n ", the users [I] id);
}
break;
}
I -;
Strcpy (users [I]. Name, name2);
Strcpy (users [I]. Password, password2);
Strcpy (users [I]. Id, id2);
Fprintf (fp, "% s % s % s", name2 [7], password2 [7], id2 [7]);
//fputs (name2 [7], fp);
//fputs (password2 [7], fp);
//fputs (id2 [20], fp);
Printf (" modify success!" );
The fclose (fp);
}
CodePudding user response:
For runs only once after the break out,The fprintf name2 [7] and the back of the several array is wrong, should use the array name, had deleted [7].
CodePudding user response: