difference between fdopen() and freopen()


 
Thread Tools Search this Thread
Top Forums Programming difference between fdopen() and freopen()
# 1  
Old 11-30-2002
Bug difference between fdopen() and freopen()

hi , I came acroos two functions fdopen() and freopen().
what is the difference between these two functions and where can they be used. Is it that fdopen() is used to write freopen().

Advance Thanks for your co-operation.

Smilie
# 2  
Old 12-02-2002
freopen is the same thing as an fclose followed by an fopen. You might use it if you had a list of list to loop through. To go the the next file, you would just freopen() it. That would close the current file and open the new file. It's ok to use freopen() even on the first file.

fdopen takes a file opened by a system call and wraps a FILE structure around it. The file stays opened, but now it looks like fopen() opened it. So now all of the standard c library stuff like fprintf() can be used on it.

You should be able to type "man fdopen" and "man freopen" to get man pages on these functions.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C fdopen with and without -ansi

I have very little experience with gcc compilation under different environments, so please bear with me. I carried over 20 years old project into Ubuntu 18.04, it has old style K&R parameters, no function declarations to speak of, many functions without return are not declared void, and on and... (8 Replies)
Discussion started by: migurus
8 Replies

2. Shell Programming and Scripting

awk to calculate difference of split and sum the difference

In the awk I am trying to subtract the difference $3-$2 of each matching $4 before the first _ (underscore) and print that value in $13. I think the awk will do that, but added comments. What I am not sure off is how to add a line or lines that will add sum each matching $13 value and put it in... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Programming

what is the main difference between difference between using nonatomic lseek and O_APPEND

I think both write at the end of the file ...... but is there a sharp difference between those 2 instruction ..... thank you this is my 3rd question today forgive me :D (1 Reply)
Discussion started by: fwrlfo
1 Replies

4. UNIX for Dummies Questions & Answers

Difference between ' and ` ...?

Hi! I just scored 82 on my first unixacademy exam (passed!!!) but there was a question I really can't figure out. I can't google it... well it doesn't come back with anything useful anyway... In short: what the difference between ' and ` ?!?! I even wasn't aware of ` ;) before... I'm not a lazy... (1 Reply)
Discussion started by: danscavo
1 Replies

5. UNIX for Advanced & Expert Users

difference...

Hi ALL, Please tell me the difference between << and < Thanks, (1 Reply)
Discussion started by: raju4u
1 Replies

6. Programming

overhead of fopen/freopen

I always assumed the fopen/freopen is very costly, so when I needed to work with many files within on process I spent extra time to implement a list of FILE * pointers to avoid extra open/reopen but it did not produced any better results. Here is a task at hand - there is a huge stream of data... (4 Replies)
Discussion started by: migurus
4 Replies

7. Shell Programming and Scripting

does someone see the difference

this works (session is set in -x) @@ecar0o:/html/dbs/public/cgi-bin> ssh ecar0o.bc -l oracle ssh cas_a "find /casa/dbcrea/`echo casa | cut -c 1-3`/rel55595 -type f ! -name '*.dbf' -exec ls -l {} \\\\\;" + cut -c 1-3 + echo casa + ssh ecar0o.bc -l oracle ssh cas_a find... (1 Reply)
Discussion started by: plelie2
1 Replies

8. UNIX for Advanced & Expert Users

what is the difference between @# and @*?

hi please provide some Examples.. Thanks in advance (6 Replies)
Discussion started by: rochitsharma
6 Replies

9. UNIX for Advanced & Expert Users

Difference between @# and @*

hi Can any one explain me difference between @# and @* with the help of examples? Thanks (3 Replies)
Discussion started by: rochitsharma
3 Replies

10. Linux

what is the difference between -h and -H ?

samba:/home/backup # df -h /home/ Filesystem Size Used Avail Use% Mounted on /dev/sdb2 34G 8.6G 26G 26% /home samba:/home/backup # df -H /home/ Filesystem Size Used Avail Use% Mounted on /dev/sdb2 37GB 9.2GB 28GB 26% /home what... (2 Replies)
Discussion started by: cw1972
2 Replies
Login or Register to Ask a Question