?
=?ISO-8859-1?Q?Andreas_M=FCller?=
Hi,
I'm working on a Linux-programm with a signal-handler and therfore I
need to use the read-system-call instead of cin.get or sth. like that.
With getline my program works fine, it reads a line from stdin and
passes it to a buffer but when I try to replace getline with read, sth.
is wrong!? can u help me?
//this works fine
length=cin.getline(cmd_buffer1,512).gcount();
for (z=0;z<length;++z){
cmd_buffer[z]=cmd_buffer1[z];
cmd_buffer[length]='\0';
//using read instead if cin.getline !?
length=read(STDIN_FILENO, cmd_buffer1, 80);
the reason why I use the for-loop (which I won't need when using
getline) is that I think I have to set the termination char (\0) myself
(when using read), is that correct?
I'm working on a Linux-programm with a signal-handler and therfore I
need to use the read-system-call instead of cin.get or sth. like that.
With getline my program works fine, it reads a line from stdin and
passes it to a buffer but when I try to replace getline with read, sth.
is wrong!? can u help me?
//this works fine
length=cin.getline(cmd_buffer1,512).gcount();
for (z=0;z<length;++z){
cmd_buffer[z]=cmd_buffer1[z];
cmd_buffer[length]='\0';
//using read instead if cin.getline !?
length=read(STDIN_FILENO, cmd_buffer1, 80);
the reason why I use the for-loop (which I won't need when using
getline) is that I think I have to set the termination char (\0) myself
(when using read), is that correct?