Solved

revers code

Posted on 1999-01-13
2
889 Views
Last Modified: 2012-05-04
i have a text file in hexa and i want to revers it contents
i want a code program how to do it sine i make this program in pl/sql but it take along time to finsh the run so i want to convert it in c languge sinec it will make it moer faster
0
Comment
Question by:areeg99
2 Comments
 
LVL 2

Expert Comment

by:hougaard
ID: 1255852
Show us the file!
0
 
LVL 3

Accepted Solution

by:
marcjb earned 50 total points
ID: 1255853
/*
  backward.c

  The code below should reverse a binary file for you.
  If you use this code on a text file, you will get some funny     results.  The CR-LF will become a LF-CR.

  To use:
    backward <infile> <outfile>    
*/

#include<stdlib.h>
#include<stdio.h>

int main(argc, argv)
int argc;
char* argv[];
{
FILE* in;
FILE* out;
unsigned char ch;

printf("\n");
if(argc != 3)
    {
    printf("USAGE: %s <infile> <outfile>\n");
    exit(1);
    }
if ( (in = fopen(argv[1], "rb")) == NULL)
    {
    printf("Could not open input file %s\n", argv[1]);
    exit(1);
    }
if ( (out = fopen(argv[2], "wb")) == NULL)
    {
    printf("Could not open input file %s\n", argv[2]);
    exit(1);
    }

fseek(in, -1, SEEK_END);
do
    {
    fread(&ch, sizeof(unsigned char), 1, in);
    fwrite(&ch, sizeof(unsigned char), 1, out);
    } while (fseek(in, -2, SEEK_CUR) == 0);


fclose(in);
fclose(out);
return 0;
}

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C simple state machine for client server handshake 4 397
C Language combined operators 28 120
Problem to ASCII 1 215
Setting nameservers after res_init fails doing res_query 2 118
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question