Beginner C/C++

Moderators: None (Apply to moderate this forum)
Number of threads: 5430
Number of posts: 16951

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
coding help Posted by chweety on 3 Jun 2007 at 6:52 AM
Hello,

Can anyone help me out to code a c/c++ program to reverse content of file without temp file
&
A code to swap higher bytes and lower bytes in integer variable
Report
Re: coding help Posted by stober on 3 Jun 2007 at 8:57 AM
: Hello,
:
: Can anyone help me out to code a c/c++ program to reverse content of
: file without temp file
: &
: A code to swap higher bytes and lower bytes in integer variable

Yes we can help you but will not write the code for you. That's your job, not ours.

To reverse a file I would read the whole file into memory then write it back out in reverse order. Do you want to do it in C or C++ (yes, there is a difference).

To swap bytes: several ways to do it. (1) use shift operator, (2) use union, (3) copy the original int binary value to a char buffer then copy back again in reverse order.
=============================================
never lie -- the government doesn't like the competition. (Author unknown)
Report
Re: coding help Posted by webcrawler on 3 Jun 2007 at 9:52 AM
: : Hello,
: :
: : Can anyone help me out to code a c/c++ program to reverse content of
: : file without temp file
: : &
: : A code to swap higher bytes and lower bytes in integer variable
:
: Yes we can help you but will not write the code for you. That's
: your job, not ours.
:
: To reverse a file I would read the whole file into memory then write
: it back out in reverse order. Do you want to do it in C or C++
: (yes, there is a difference).
:
: To swap bytes: several ways to do it. (1) use shift operator, (2)
: use union, (3) copy the original int binary value to a char buffer
: then copy back again in reverse order.
: =============================================
: never lie -- the government doesn't like the competition. (Author
: unknown)

you could also use fseek(file, SEEK_END) and read each line backwards, then ouput.
Report
Re: coding help Posted by stober on 3 Jun 2007 at 11:39 AM
: : : Hello,
: : :
: : : Can anyone help me out to code a c/c++ program to reverse content of
: : : file without temp file
: : : &
: : : A code to swap higher bytes and lower bytes in integer variable
: :
: : Yes we can help you but will not write the code for you. That's
: : your job, not ours.
: :
: : To reverse a file I would read the whole file into memory then write
: : it back out in reverse order. Do you want to do it in C or C++
: : (yes, there is a difference).
: :
: : To swap bytes: several ways to do it. (1) use shift operator, (2)
: : use union, (3) copy the original int binary value to a char buffer
: : then copy back again in reverse order.
: : =============================================
: : never lie -- the government doesn't like the competition. (Author
: : unknown)
:
: you could also use fseek(file, SEEK_END) and read each line
: backwards, then ouput.
:

that will not change the contents of the file only display it backwards. It will work if that is what OP wants to do.

=============================================
never lie -- the government doesn't like the competition. (Author unknown)
Report
Re: coding help Posted by red3warlord on 4 Jun 2007 at 1:15 AM
: : : : Hello,
: : : :
: : : : Can anyone help me out to code a c/c++ program to reverse content of
: : : : file without temp file
: : : : &
: : : : A code to swap higher bytes and lower bytes in integer variable
: : :
: : : Yes we can help you but will not write the code for you. That's
: : : your job, not ours.
: : :
: : : To reverse a file I would read the whole file into memory then write
: : : it back out in reverse order. Do you want to do it in C or C++
: : : (yes, there is a difference).
: : :
: : : To swap bytes: several ways to do it. (1) use shift operator, (2)
: : : use union, (3) copy the original int binary value to a char buffer
: : : then copy back again in reverse order.
: : : =============================================
: : : never lie -- the government doesn't like the competition. (Author
: : : unknown)
: :
: : you could also use fseek(file, SEEK_END) and read each line
: : backwards, then ouput.
: :
:
: that will not change the contents of the file only display it
: backwards. It will work if that is what OP wants to do.
:
: =============================================
: never lie -- the government doesn't like the competition. (Author
: unknown)

hi to you...

seems like you have a big problem, am i right?

and that is y ou don't persue yourself to study for it...

you have to focus on it so that you will get what you want to attain...

i can give you not the code,
but a prob that will force you to persue on it...

i hope this will help you to make yourself be active in terms of
persuation and networking, and at the same time, brainstorming and creativity.....

this wold be the prob:

a teacher has difficult time in computing the average grade of her 5 students, namely Joseph, Marvin, Antonio, Louis, and Mark. There average
grade will be computed by this format:

average grade = (FirstGrade + SecondGrade + ThirdGrade + FourthGrade) / 4

Make a program that can compute the average grade of each student of the teacher.



from red3warlord with gratitude always saying...



"never lie on the present
and make focus for the future..."



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.