Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

revers code

Posted on 1999-01-13
2
Medium Priority
?
892 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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 opening and writing to files in the C programming language.

722 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