>so i can print a text file in revese character and reverse line order
There are a number of ways to do this, but fseek is virtually useless for text streams. You might want to consider an alternate method such as reading the file into a buffer and printing the buffer in reverse or recursion:
Code:
#include <stdio.h>
#include <string.h>
static void pr_revLine ( FILE *fp )
{
char buf[BUFSIZ] = {'\0'};
if ( fgets ( buf, (int)sizeof buf, fp ) != NULL ) {
buf[strcspn(buf, "\n")] = '\0';
pr_revLine ( fp );
(void)puts ( buf );
}
}
static void pr_revChar ( FILE *fp )
{
int ch;
if ( ( ch = fgetc ( fp ) ) != EOF ) {
pr_revChar ( fp );
(void)putchar ( ch );
}
}
int main ( void )
{
FILE *fp;
fp = fopen ( "input.txt", "r" );
if ( fp != NULL ) {
pr_revLine ( fp );
rewind ( fp );
pr_revChar ( fp );
(void)fclose ( fp );
}
(void)putchar ( '\n' );
return 0;
}
-Prelude