473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

file handling operation

HI all,

I have to write a C program ,suppose if i want to tranfer 1MB from
host memory to device say SD ,first i have to split it into 5kbytes
after having splitted into 5kbytes each, not more than that(spiliting
can be uniform or random)...even i can have less than 5k....

I will use one file and make it executable,and dump fields specifying
such as data transfer size,source address,destination address and
next pointer in it.

i have to read that file for data and write the data into the some
other address in that file.

pls give your how to proceed and how can i enter the different fields
and access through file pointer?

thanks in advance..

regards,
fazal

Jul 19 '07 #1
5 1977
On Thursday 19 Jul 2007 10:46 am, fazulu deen <fa*********@gmail.com>
wrote in message
<11**********************@x35g2000prf.googlegroups .com>:
HI all,

I have to write a C program ,suppose if i want to tranfer 1MB from
host memory to device say SD ,first i have to split it into 5kbytes
after having splitted into 5kbytes each, not more than
that(spiliting can be uniform or random)...even i can have less
than 5k....

I will use one file and make it executable,and dump fields
specifying such as data transfer size,source address,destination
address and next pointer in it.

i have to read that file for data and write the data into the some
other address in that file.

pls give your how to proceed and how can i enter the different
fields and access through file pointer?

thanks in advance..
One can't really say without knowing more detailed information. Is
you device accessible as a normal C stream? If so, you could
probably fwrite to it, and let the system take care of the details.

What format is your file in? What is the format of the "fields" in
your file? What exactly are the "source address" and "destination
address"? Are they memory addresses or file offsets? You can
probably use fread to read in your "header" block, which supposedly
specifies the details of the "transfer". You could then seek to the
offset where the source data begins, read it into a buffer, seek to
the offset where you should write, and write the data out.

There are a lot of details, gotchas and caveats when it comes to
simultaneous reading and writing of files. We can't tell you more
without more details of your setup.

Jul 19 '07 #2
On Thursday 19 Jul 2007 10:46 am, fazulu deen <fa*********@gmail.com>
wrote in message
<11**********************@x35g2000prf.googlegroups .com>:
HI all,
[ ... ]
i have to read that file for data and write the data into the some
other address in that file.

pls give your how to proceed and how can i enter the different
fields and access through file pointer?
Also I should mention the very informative FAQ for this group. Be
sure to read it:

<http://www.c-faq.com>
Jul 19 '07 #3
On Wed, 18 Jul 2007 22:16:41 -0700, in comp.lang.c , fazulu deen
<fa*********@gmail.comwrote:
>HI all,

I have to write a C program ,suppose if i want to tranfer 1MB from
host memory to device say SD ,first i have to split it into 5kbytes
after having splitted into 5kbytes each, not more than that(spiliting
can be uniform or random)...even i can have less than 5k....
This isn't a C question, so you need to ask in a different group.

First work out your algorithm, then decide what language to code it
in. If you /have/ to use C for some reason, break your algorithm down
into units, try to implement them and ask for advice when you have
problems. My guess is that once you understand the algo and have
defined sensible units required to make it work, you will also
understand how to solve the problem.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jul 19 '07 #4
Mark McIntyre <ma**********@spamcop.netwrites:
On Wed, 18 Jul 2007 22:16:41 -0700, in comp.lang.c , fazulu deen
<fa*********@gmail.comwrote:
>>HI all,

I have to write a C program ,suppose if i want to tranfer 1MB from
host memory to device say SD ,first i have to split it into 5kbytes
after having splitted into 5kbytes each, not more than that(spiliting
can be uniform or random)...even i can have less than 5k....

This isn't a C question, so you need to ask in a different group.
"I have to write a C program". Seems like a C question to me. It might
be OT and homework etc, but it's most definitely tightly couple with C.
>
First work out your algorithm, then decide what language to code it
in. If you /have/ to use C for some reason, break your algorithm down
"I have to write a C program"
into units, try to implement them and ask for advice when you have
problems. My guess is that once you understand the algo and have
defined sensible units required to make it work, you will also
understand how to solve the problem.
You're so quick to pick holes in people posts that you forget to read
them!
Jul 20 '07 #5
fazulu deen <fa*********@gmail.comwrote:
# HI all,
#
# I have to write a C program ,suppose if i want to tranfer 1MB from
# host memory to device say SD ,first i have to split it into 5kbytes
# after having splitted into 5kbytes each, not more than that(spiliting
# can be uniform or random)...even i can have less than 5k....
#
# I will use one file and make it executable,and dump fields specifying
# such as data transfer size,source address,destination address and
# next pointer in it.
#
# i have to read that file for data and write the data into the some
# other address in that file.

If you're trying to read a file into a block of memory (mapped to
a device?), you can do something like
in = fopen(filename,"r...")
out = least byte address of memory block
transfersize = 5k
while ((bytesread=fread(out,1,transfersize,in))>0)
out += bytesread;

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Where do you get those wonderful toys?
Jul 21 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: deko | last post by:
Do I need to use flock() when reading a file into an array? It's possible that the file in question could be open at the time the file('filename') request is made. I realize flock() is required...
5
by: Hans-Joachim Widmaier | last post by:
Recently, there was mentioned how someone who had understood Python's error handling would write the "open and read file with error handling" idiom. If I remember correctly, it went like this: ...
9
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is...
5
by: juergen perlinger | last post by:
Hello out there. sometimes I need to have proper control of the floating point arithmetic of the C(and C++) runtime system, and using the f.p. exception handling of the C99 standard is quite...
34
by: rawCoder | last post by:
I have read that Exception Handling is expensive performance wise ( other than Throw ) , but exactly how ? Please consider the following example ... ////////////////// Code Block 1...
7
by: John Dann | last post by:
I'm tripping over a silly little problem when trying to read a text file, but can't see the fix. Outline code is: ---------------------------------------------------- FS=New FileStream(filename,...
4
by: Tad Marshall | last post by:
Hi, I'm having limited luck getting an ApplicationException to work right in my code. This is VB.NET, VS 2003, Windows XP SP2, .NET Framework 1.1. I thought it would be convenient to take...
2
by: Kevin Frey | last post by:
One of my chief criticisms of validators in an ASP.NET page is that they can result in a developer re-implementing much of the "business logic" of a transaction at the page level. Assuming we...
11
by: Gina_Marano | last post by:
Hey all, I need to validate a large binary file. I just need to read the last 100 or so bytes of the file. Here is what I am currently doing but it seems slow: private bool ValidFile(string...
9
by: arnuld | last post by:
Can anyone point me to some online/offline document on error handling in C ? I am doing some Socket Programming in C and feeling a lots of difficult in error handling :( Also some time ago...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.