Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Weird problem in Reading a file (C Language)

Status
Not open for further replies.

agent_009

Member level 2
Member level 2
Joined
Dec 17, 2006
Messages
47
Helped
10
Reputation
20
Reaction score
3
Trophy points
1,288
Activity points
1,563
Hi,

I am stuck with a weird problem that i am not able to understand.

I am trying to make a utility in C language that extracts a part of an MP3 file and writes it to an output file.

What i am currently doing is that i open the input file using _open() in binary mode and read the file byte by byte using _read(). However when it reads byte 1Ah (26 in decimal), _read() returns 0 indicating End Of File. This byte is the 103rd byte in the file, which is almost the start of file, so it is actually not the end of file. The file itself is of size 2.89 MB.
Secondly, EOF is defined as -1 not 26. So why is _read() indicating EOF.

By the way i have also tried fread() but it also has the same problem.

I am using MS Visual Studio 2000 under Windows XP.


Please suggest some solution as this problem is driving me crazy.

Thanx
 

Re: Problem in C Programming

post the code you have written
 

    agent_009

    Points: 2
    Helpful Answer Positive Rating
Never mind, the problem is solved. Actually, there was a mistake in the code and i was opening the file in Text mode rather than binary mode. Opening the file in binray mode works fine.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top