User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 427,463 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,572 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums

FILE + conversion from dec to hex = I need help

Join Date: Jun 2006
Location: India
Posts: 6,863
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 344
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: FILE + conversion from dec to hex = I need help

  #7  
Nov 12th, 2006
Okay here are a few pointers:

1. Use int main( ) not just main( ) and append a return 0 stmt at the end of main( ).

2. Dont hard code the file names in the function, its not a good practice. Just keep the file name in a constant array of characters.

3. I am not sure on this one, but, dont use \\ in your file paths, it is not cross platform complaint. Use forward slashes instead ( / ).

4. After opening the files do check whether the operation is successful, it is a good practice.

  1. FILE* fp ;
  2. if( ( fp = fopen( "a.txt", "r" ) ) == NULL )
  3. {
  4. fputs( "file opening failed", stderr ) ;
  5. exit( 1 ) ;
  6. }

5. fscanf( ) normally returns the number of items scanned and in the case of error a NULL is returned.
Last edited by ~s.o.s~ : Nov 12th, 2006 at 12:59 pm.
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
All times are GMT -4. The time now is 6:03 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC