Solved

revers code

Posted on 1999-01-13
2
884 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now