Solved

revers code

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

744 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

10 Experts available now in Live!

Get 1:1 Help Now