Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

revers code

Posted on 1999-01-13
2
Medium Priority
?
894 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 100 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Suggested Courses

877 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