If I understand it correctly, the file to be read has the following format:
1. The first line contains an integer n indicating the number of iterated sequences. The next n lines each contain a sequence of iterated values.
2. Each of these lines starts with an integer m indicating the number of iterated values in the sequence. The rest of the line contains the list of m space-separated values in the sequence.
3. The next line contains an integer p indicating the number of password changes to be examined. The following p lines contain two values separated by spaces, indicating the old and the new password, respectively.
Example input file:
6
10 0 1 2 3 4 5 6 7 8 9
12 January February March April May June July August September October November December
7 Monday Tuesday Wednesday Thursday Friday Saturday Sunday
3 qwerty asdf zxcv
2 ana bob
3 ? . !
20
password1 password2
Pass123 pass124
ShhMonday ShhMarch
January23 March23
ABCJanuary MarchABC
January23 february23
Tuesday Sunday
xyz123 124xyz
zxcvz qwertyz
asdfasdf asdfzxcv
asdfasdf zxvcasdf
bobobob anaobob
bobobob boboana
banana bbobna
banana banbob
banana baboba
password!!! !password!!
password!!! password???
password?!! password?!?
password!!! password!?!
...
Obviously, a file with input values must be read first. For this one must open the file and store the contents in suitable structures.
1. In the main function the file "mydata.dat" is opened in the read mode. If the file cannot be opened, an error message is output.
2. The number of sequences n to be processed is read from the file.
3. An array of sequence structures (sequences) is dynamically allocated to store the sequences. Each sequence has a length and an array of values. The sequence structure contains information about the number of values and an array to store these values.
4. In a loop for each sequence the number of values m is read, then dynamically memory is reserved for the values of this sequence and the values are read from the file.
5. The number of password changes p to be processed is read from the file.
6. An array of PWChange structures is dynamically allocated to store the password changes. The PWChange structure stores information about password changes. It contains fields for the old and the new password.
7. In a loop the old and new passwords are read from the file and stored in the corresponding fields of PWChange structures.
8. After all data have been read in, the file can be closed and work can be done with the data.
At the end of the program, the allocated memory should be released. First the values in the sequences are released, then the sequences themselves, and finally the password changes.
A C program for this could start like this:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
int length; char **values; } Sequence;
typedef struct {
char oldPassword[32]; char newPassword[32]; } PWChange;
int main()
{
FILE* file; int n; int m; int p;
Sequence* sequences; PWChange* pwChanges;
if (fopen_s(&file, "mydata.dat", "r") != 0) {
perror("Error opening file"); return 1;
}
fscanf_s(file, "%d", &n);
...
fclose(file);
return 0;
}
No one will give you a complete solution, but I hope this framework is enough to give you an idea of what the complete solution might look like. It would be necessary that you get to know the required functions and deal with them.