You have to set
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 CENTOS
sd_journal_stream_fd
SD_JOURNAL_STREAM_FD(3) sd_journal_stream_fd SD_JOURNAL_STREAM_FD(3)NAME
sd_journal_stream_fd - Create log stream file descriptor to the journal
SYNOPSIS
#include <systemd/sd-journal.h>
int sd_journal_stream_fd(const char* identifier, int priority, int level_prefix);
DESCRIPTION
sd_journal_stream_fd() may be used to create a log stream file descriptor. Log messages written to this file descriptor as simple
newline-separated text strings are written to the journal. This file descriptor can be used internally by applications or be made
STDOUT/STDERR of other processes executed.
sd_journal_stream_fd() takes a short program identifier string as first argument, which will be written to the journal as
_SYSLOG_IDENTIFIER= field for each log entry (see systemd.journal-fields(7) for more information). The second argument shall be the default
priority level for all messages. The priority level is one of LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO,
LOG_DEBUG, as defined in syslog.h, see syslog(3) for details. The third argument is a boolean: if true kernel-style log priority level
prefixes (such as SD_WARNING) are interpreted, see sd-daemon(3) for more information.
It is recommended that applications log UTF-8 messages only with this API, but this is not enforced.
RETURN VALUE
The call returns a valid write-only file descriptor on success or a negative errno-style error code.
NOTES
The sd_journal_stream_fd() interface is available as a shared library, which can be compiled and linked to with the libsystemd-journal pkg-
config(1) file.
EXAMPLES
Creating a log stream suitable for fprintf(3):
#include <syslog.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <systemd/sd-journal.h>
#include <systemd/sd-daemon.h>
int main(int argc, char *argv[]) {
int fd;
FILE *log;
fd = sd_journal_stream_fd("test", LOG_INFO, 1);
if (fd < 0) {
fprintf(stderr, "Failed to create stream fd: %s
", strerror(-fd));
return 1;
}
log = fdopen(fd, "w");
if (!log) {
fprintf(stderr, "Failed to create file object: %m
");
close(fd);
return 1;
}
fprintf(log, "Hello World!
");
fprintf(log, SD_WARNING "This is a warning!
");
fclose(log);
return 0;
}
SEE ALSO systemd(1), sd-journal(3), sd-daemon(3), sd_journal_print(3), syslog(3), fprintf(3), systemd.journal-fields(7)systemd 208SD_JOURNAL_STREAM_FD(3)