<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
<small>Hi all,<br>
<br>
I am writing user- space driver. My intention is to print whatever
string i am enter into terminal. <br>
<br>
Here i am using setbuf function to sent the data to the print
after some fixed string length.<br>
<br>
I wrote below program for understand setbuf functionality. But i
am getting unpredictable result for some output . can any one
explain the why i am getting these result. <br>
<br>
root@desktop:/home/prabhu# cat a.c <br>
<font color="#000099">#include <stdio.h><br>
main()<br>
{<br>
char buff2[]= "hello world";<br>
char buf1[6]="";<br>
setbuf(stdin, buf1);<br>
getchar();<br>
printf ("%s",buf1);<br>
}<br>
</font><br>
<br>
root@desktop:/home/prabhu# cc a.c <br>
root@desktop:/home/prabhu# ./a.out <br>
a<br>
a<br>
root@desktop:/home/prabhu# ./a.out <br>
aa<br>
aa<br>
root@desktop:/home/prabhu# ./a.out <br>
aaa<br>
aaa<br>
root@desktop:/home/prabhu# ./a.out <br>
aaaa<br>
aaaa<br>
root@desktop:/home/prabhu# ./a.out <br>
aaaaa<br>
aaaaa<br>
hello worldroot@desktop:/home/prabhu# ./a.out <br>
aaaaaa<br>
aaaaaa<br>
ello worldroot@desktop:/home/prabhu# ./a.out <br>
aaaaaaa<br>
aaaaaaa<br>
llo worldroot@desktop:/home/prabhu# ./a.out <br>
aaaaaaaa<br>
aaaaaaaa<br>
lo worldroot@desktop:/home/prabhu# ./a.out <br>
aaaaaaaaa<br>
aaaaaaaaa<br>
o worldroot@desktop:/home/prabhu# ./a.out <br>
aaaaaaaaaa<br>
aaaaaaaaaa<br>
worldroot@desktop:/home/prabhu# ./a.out <br>
aaaaaaaaaaa<br>
aaaaaaaaaaa<br>
<br>
<br>
Thanks,<br>
Prabhu<br>
</small>
</body>
</html>