I would consider using a higher level call like fprintf() which is easier to use, especially since you seem to be writing single characters to the output stream.
Hi,
How to replace any character in a file with a newline character using sed ..
Ex:
To replace ',' with newline
Input:
abcd,efgh,ijkl,mnop
Output:
abcd
efgh
ijkl
mnop
Thnx in advance.
Regards,
Sasidhar (5 Replies)
Hello,
I'm trying to write a method which will return the extension of a file given the file's name, e.g. test.txt should return txt. I'm using C so am limited to char pointers and arrays. Here is the code as I have it:
char* getext(char *file)
{
char *extension;
int i, j;... (5 Replies)
hello everybody!
i have aproblem! i dont know how to concatenate const char* with char
const char *buffer;
char *b;
sprintf(b,"result.txt");
strcat(buffer,b);
thanx in advance (4 Replies)
Hi All,
char a="\0";
a) a contains \0
a contains garbage value
b) a contains \
a contains 0
a contains garbage value
Pls, let me know correct result is a or b. I guess a.
Thanks,
Naga:cool: (2 Replies)
if ; then => is it correct?
i need to check 10 files size and do the same action. The file name is same but extension of the files are different. how do i deal with it? Please help (1 Reply)
Hi
I m having ifconfig -a o/p like
sbanlab1:ksh# ifconfig -a | egrep "flags|inet" | awk -F' ' '{print $1,$2}'
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL>
inet 127.0.0.1
lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL>
inet 127.0.0.1
bge0:... (1 Reply)
Compiling xpp (The X Printing Panel) on SL6 (RHEL6 essentially):
xpp.cxx: In constructor ‘printFiles::printFiles(int, char**, int&)’:
xpp.cxx:200: error: invalid conversion from ‘const char*’ to ‘char*’
The same error with all c++ constructors - gcc 4.4.4.
If anyone can throw any light on... (8 Replies)
Pointers are seeming to get the best of me and I get that error in my program.
Here is the code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define REPORTHEADING1 " Employee Pay Hours Gross Tax Net\n"
#define REPORTHEADING2 " Name ... (1 Reply)
Discussion started by: Plum
1 Replies
LEARN ABOUT OPENSOLARIS
ftrylockfile
flockfile(3C) Standard C Library Functions flockfile(3C)NAME
flockfile, funlockfile, ftrylockfile - acquire and release stream lock
SYNOPSIS
#include <stdio.h>
void flockfile(FILE *stream);
void funlockfile(FILE *stream);
int ftrylockfile(FILE *stream);
DESCRIPTION
The flockfile() function acquires an internal lock of a stream stream. If the lock is already acquired by another thread, the thread call-
ing flockfile() is suspended until it can acquire the lock. In the case that the stream lock is available, flockfile() not only acquires
the lock, but keeps track of the number of times it is being called by the current thread. This implies that the stream lock can be
acquired more than once by the same thread.
The funlockfile() function releases the lock being held by the current thread. In the case of recursive locking, this function must be
called the same number of times flockfile() was called. After the number of funlockfile() calls is equal to the number of flockfile()
calls, the stream lock is available for other threads to acquire.
The ftrylockfile() function acquires an internal lock of a stream stream, only if that object is available. In essence ftrylockfile() is a
non-blocking version of flockfile().
RETURN VALUES
The ftrylockfile() function returns 0 on success and non-zero to indicate a lock cannot be acquired.
EXAMPLES
Example 1 A sample program of flockfile().
The following example prints everything out together, blocking other threads that might want to write to the same file between calls to
fprintf(3C):
FILE iop;
flockfile(iop);
fprintf(iop, "hello ");
fprintf(iop, "world);
fputc(iop, 'a');
funlockfile(iop);
An unlocked interface is available in case performance is an issue. For example:
flockfile(iop);
while (!feof(iop)) {
*c++ = getc_unlocked(iop);
}
funlockfile(iop);
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO Intro(3), __fsetlocking(3C), ferror(3C), fprintf(3C), getc(3C), putc(3C), stdio(3C), ungetc(3C), attributes(5), standards(5)NOTES
The interfaces on this page are as specified in IEEE Std 1003.1:2001. See standards(5).
SunOS 5.11 10 Sep 2003 flockfile(3C)