HP C/iX Library Reference Manual (30026-90004)
Chapter 5 295
HP C/iX Library Function Descriptions
rewind
}
pswd = fopen(argv[1], "r");
if(pswd == NULL) {
fprintf(stderr, "Can't open %s.\n", argv[1]);
exit(1);
}
fgets(line, 256, pswd);
if(line[0] == '*' line[1] == 'P') {
/* ask for and check password */
} else
rewind(pswd);
/* application program goes here */
exit(0);
}
If the first two characters of the first line are "*P", the code that asks for and checks a
password is executed. However, if the first line is not a password line, the file is assumed to
be unprotected. Thus, the file must be rewound so the data contained in the first line is
available to the application program.
See Also
ftell(), fseek(), ANSI C 4.9.9.5, POSIX.1 8.1