02-15-2011
In the case of fread()/fwrite() it's even worse than that.
Both fread() and fwrite() by default buffer IO within the process's address space, so the OS may not even know that the application has made either call.
If you want to do concurrent access like that, you should probably use lower-level calls like read() and write(). Even then, you need to be concerned with applications not "seeing" things like changes in file size, for example.
And you do NOT want to be trying this on an NFS file system.
10 More Discussions You Might Find Interesting
1. Programming
Hi...
I am trying to read a binary data that have different types of messages of different lengths. I am using fread() but this functions needs the size and count to read the buffer from the file. I think this may cause that the buffer overlaps other messages.
Is there an alternative to read... (1 Reply)
Discussion started by: jlrodz
1 Replies
2. Programming
After my previous thread, I think I found out what causes the long delays.
I run this program on several Linux computers, and the sometimes (after the file with the arrays becomes big) the fwrite takes between 100 ms to 900 ms.
This is very bad for me, as I want a timer to halt each 30 ms.... ... (5 Replies)
Discussion started by: inna
5 Replies
3. Programming
Hi ,
I am running a C/C++ program on a solaris 5.8 machine. This parituclar application has a module which saves data to a file. The module uses fwrite() function to save data.
The fwrite function write about 500 MB of data to a file. The problem which I am facing is, the memory consumtion... (2 Replies)
Discussion started by: ajphaj
2 Replies
4. Programming
Code : function sSaveTFFile
.......................
iRetCode = link (caCurrentFilename, caBackupFilename);
if (iRetCode == -1)
{
ERR_MSG2(LOG_ALERT, "Can't move %s to %s", caCurrentFilename, caBackupFilename);
return(FAILURE);
}
iRetCode = unlink... (6 Replies)
Discussion started by: fermisoft
6 Replies
5. Programming
Hi All,
These are the two ways i tried to read file but i getting work with second one not with the first.
char buf; // Defining space for buf
ctrlfnum = fopen(filename_arr.control_fname,"r");
1) n = fread(buf,sizeof(buf),1,ctrlfnum); ============== (not works)
2) n =... (4 Replies)
Discussion started by: arunkumar_mca
4 Replies
6. Programming
Hi
I have an fwrite function in my C++ application. It is able to create the files in HP-UX.
cross is one structure
rec2 is another structure within cross.
fwrite_return = fwrite( &cross.rec2,
sizeof(cross.rec2),
... (14 Replies)
Discussion started by: rkraj
14 Replies
7. Programming
Hello All,
I tried to test a sample fread example to read a complete file
and the code is
#include <stdio.h>
#include <stdlib.h>
int main () {
FILE * pFile;
long lSize;
char * buffer;
size_t result;
pFile = fopen ( "test.xml" , "rb" );
if (pFile==NULL) {fputs ("File... (11 Replies)
Discussion started by: quintet
11 Replies
8. Programming
Hi,
my code is written in proC and it is in UNIX(AIX).I have written a small code for writing data into a binary file,but while writing my program is giving core dump.
Here Is my code----
fpWriteFile = fopen(WriteFileName,"wb+");
CHAR *recvgen;
recvgen = (char... (7 Replies)
Discussion started by: ajaysahoo
7 Replies
9. Programming
When fread is used twice, the second time it seems to overwrite the first time's output. Is there any way to clear fread's internal buffer after each use ?
char *FILEREAD(const char *FILENAME)
{
static char READBUFFER = "";
READBUFFER = '\0'; // try to solve the problem but this will not... (2 Replies)
Discussion started by: limmer
2 Replies
10. Programming
Hello,
I am trying to read a text file into linked list, but always got the first and last records wrong.
1) The problem looks related to the initialization of the node temp with malloc(), but could not figure it out. No error/warning at compiling, though.
2) The output file is empty,... (10 Replies)
Discussion started by: yifangt
10 Replies