Sponsored Content
Full Discussion: open file stream problem
Top Forums Programming open file stream problem Post 56417 by ivancheung on Saturday 2nd of October 2004 05:57:00 AM
Old 10-02-2004
open file stream problem

I have faced a problem that I use 2 file streams in a function and try to fopen() both files. Then I can't get the file descriptor. But if I just use 1 file stream and 1 fopen(), then i can get the file descriptor. Does anybody know why this happens? Thanks in advance.

Code:
toFileStream=fdopen(localFileDes,"a+")
toFileStream=fopen(fromFile,"r+")

 

10 More Discussions You Might Find Interesting

1. Programming

File I/O Stream

Hi All, I am trying to read data from two files and then compare them and only print the records on the screen that have a same ID.i.e TAGNO =CUSTOMERNO For Eg My Input Files are (a) Transaction (b) Customer detail The data in file a is like: TagNo Date Time Station... (0 Replies)
Discussion started by: rooh
0 Replies

2. Solaris

Pla help - urgent-netstat error--- cant open mib stream

Hi, When i type netstat command as normal user it shows following error $ netstat arp open: Permission denied can't open mib stream I can execute the command as root user.. Pls reply at the earliest (1 Reply)
Discussion started by: vadivukumar
1 Replies

3. Shell Programming and Scripting

[Video stream] network stream recording with mplayer

Hi I used this command: mplayer http://host/axis-cgi/mjpg/video.cgi -user root -passwd root \ -cache 1024 -fps 25.0 -nosound -vc ffh264 \ -demuxer 3 -dumpstream -dumpfile output.avi It's ok but... Video Playing is very fast! Why? Is it a synch problem? What parameter I have to use for... (1 Reply)
Discussion started by: takeo.kikuta
1 Replies

4. Red Hat

cannot set user id: Resource temporarily unavailable (not open file/open process related)

First post, sorry to be a bother but this one has been dogging me. I have a process user (java application server) that trips a resource limit every couple weeks and need help finding what limit we're hitting. First, this is what's running: This is the error when jobs are run or the... (0 Replies)
Discussion started by: Katahdin
0 Replies

5. Shell Programming and Scripting

Stream all log files into one file

Here is what I have. 1 main program and it calls several child programs. Each child has its own log file. I want all child logs also to be appended to the main.log so that I have a single log file. I also need individual child logfiles in tact for debug purposes. Need to be able to tail one log... (4 Replies)
Discussion started by: myjunk1
4 Replies

6. Shell Programming and Scripting

Removing all lines prior to the last pattern in a file/stream

Hi all, I didn't find anything that specifically answers this after searching for a bit, so please forgive me if this has been covered before. I'm looking to delete all lines prior to the last occurrence of a string in a file or stream from within a shell script (bash.) A bit of... (4 Replies)
Discussion started by: LivinFree
4 Replies

7. UNIX for Dummies Questions & Answers

What is an (application/octet-stream) file?

I'm trying to learn as much about GRUB as I can and it's stages are stored in these types of files. Any info or search terms is appreciated!:wall: (5 Replies)
Discussion started by: theKbStockpiler
5 Replies

8. Shell Programming and Scripting

Creating a file from input stream

Hi, Need some help with creating a file from input steam. Meaning from following command myfunc should be able to store the input stream to a file. echo a b c | myfunc The file thus created should have - a b c Here's what I've tried in myfunc() but didn't help - myfunc() { cat... (3 Replies)
Discussion started by: nexional
3 Replies

9. Shell Programming and Scripting

Wget for downloading a public file (stream) as mp4

I need a hint for using wget for getting a free content from a TV station that is streaming its material for a while until it appears on any video platform, that means no use of illegal methods, because it is on air, recently published and available. But reading the manual for wget I tried the... (5 Replies)
Discussion started by: 1in10
5 Replies

10. Windows & DOS: Issues & Discussions

Play STRG - E-Viewer Recorded Stream file

I have got a .strg file, which I cannot open. I tried NMS Player from Novus, but It can't handle STRG files. How can I play these recordings? (1 Reply)
Discussion started by: kovacsdev
1 Replies
FOPEN(3)						   BSD Library Functions Manual 						  FOPEN(3)

NAME
fopen, fdopen, freopen -- stream open functions LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdio.h> FILE * fopen(const char * restrict path, const char * restrict mode); FILE * fdopen(int fildes, const char *mode); FILE * freopen(const char * restrict path, const char * restrict mode, FILE * restrict stream); DESCRIPTION
The fopen() function opens the file whose name is the string pointed to by path and associates a stream with it. The argument mode points to a string beginning with one of the following sequences (Additional characters may follow these sequences.): ``r'' Open for reading. ``r+'' Open for reading and writing. ``w'' Open for writing. Truncate file to zero length or create file. ``w+'' Open for reading and writing. Truncate file to zero length or create file. ``a'' Append; open for writing. The file is created if it does not exist. ``a+'' Append; open for reading and writing. The file is created if it does not exist. Additionally: o The mode string can also include the letter ``b'' either as a last character or as a character between the characters in any of the two-character strings described above. This is strictly for compatibility with ANSI X3.159-1989 (``ANSI C89'') and has no effect; the ``b'' is ignored. o The letter ``f'' in the mode string restricts fopen() to regular files; if the file opened is not a regular file, fopen() will fail. This is a non ANSI X3.159-1989 (``ANSI C89'') extension. o The letter ``e'' in the mode string sets the close-on-exec flag in the file descriptors of the newly opened file files; if the opera- tion fails, fopen() will fail. This is a non ANSI X3.159-1989 (``ANSI C89'') extension. o The letter 'x' in the mode turns on exclusive open mode to the file ( O_EXCL) which means that the file will not be created if it already exists. Any created files will have mode "S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH" (0666), as modified by the process' umask(2) value. Opening a file with append mode causes all subsequent writes to it to be forced to the then current end of file, regardless of intervening repositioning of the stream. The fopen() and freopen() functions initially position the stream at the start of the file unless the file is opened with append mode, in which case the stream is initially positioned at the end of the file. The fdopen() function associates a stream with the existing file descriptor, fildes. The mode of the stream must be compatible with the mode of the file descriptor. The stream is positioned at the file offset of the file descriptor. The freopen() function opens the file whose name is the string pointed to by path and associates the stream pointed to by stream with it. The original stream (if it exists) is closed. The mode argument is used just as in the fopen() function. The primary use of the freopen() function is to change the file associated with a standard text stream (stderr, stdin, or stdout). RETURN VALUES
Upon successful completion fopen(), fdopen() and freopen() return a FILE pointer. Otherwise, NULL is returned and the global variable errno is set to indicate the error. ERRORS
The functions may fail if: [EFTYPE] The file is not a regular file and the character ``f'' is specified in the mode. [EINVAL] The specified mode was invalid. The fopen(), fdopen() and freopen() functions may also fail and set errno for any of the errors specified for the routine malloc(3). The fopen() function may also fail and set errno for any of the errors specified for the routine open(2). The fdopen() function may also fail and set errno for any of the errors specified for the routine fcntl(2). The freopen() function may also fail and set errno for any of the errors specified for the routines open(2), fclose(3) and fflush(3). SEE ALSO
open(2), fclose(3), fileno(3), fseek(3), funopen(3) STANDARDS
The fopen() and freopen() functions conform to ANSI X3.159-1989 (``ANSI C89''). All three functions are specified in IEEE Std 1003.1-2008 (``POSIX.1''). CAVEATS
Proper code using fdopen() with error checking should close(2) fildes in case of failure, and fclose(3) the resulting FILE * in case of suc- cess. FILE *file; int fd; if ((file = fdopen(fd, "r")) != NULL) { /* perform operations on the FILE * */ fclose(file); } else { /* failure, report the error */ close(fd); } BSD
November 14, 2012 BSD
All times are GMT -4. The time now is 08:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy