On Tue, 2005-03-29 at 13:07 +0200, Erik Mouw wrote: > On Tue, Mar 29, 2005 at 04:26:31PM +0530, Mandeep Sandhu wrote: > > On Tue, 2005-03-29 at 12:31 +0200, Erik Mouw wrote: > > > On Tue, Mar 29, 2005 at 03:54:13PM +0530, Mandeep Sandhu wrote: > > > Literial \0 after the string, so string is too long. > > the '\0' got appended at the end when i created the string.... > > I'm don't get what you mean by string being too long. > > You shouldn't copy it to userland. \0 happens to be the string > terminator used in C, but it is by no means a general string > terminator. > > > > > count = sizeof(msg); > > > > > > Here's your error, that should be count = strlen(msg); > > > > > strlen(msg) is 5. (i.e the length of the string) > > sizeof(msg) is 6. (length + the null terminating char) > > > > so while copying data into the userspace buffer...I should > > omit copying this null term ('\0') char???? won't the user > > prog be expecting this at the end of the string? or it'll (cat) > > handle it on it's own? > > No, userland doesn't expect it, and it will confuse your terminal. > printf() used in userland programs also doesn't print a \0 after every > line, and with reason: \0 is *only* the string terminator used > internally in C, *not* a way to signal end-of-file to userland. > ok folks! i tried strlen too......but to no avail! :( still only putting `\n' does the trick! what say Erik? > > Erik > -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/