file handling operation

F

fazulu deen

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
 
S

santosh

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.
 
M

Mark McIntyre

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
 
R

Richard

Mark McIntyre said:
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!
 
S

SM Ryan

# 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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top