How do I write a function to modify a file in Unix where I created a newfile and I'm attempting to add char's to the file, but when I add the char's it appends it on the same line. I want it to go to the next line and add then next line and add. Example below:
wrong:What I don't want it to do
/bin/sh/bin/ksh/bin/csh
right:What I want it to do
/bin/sh
/bin/ksh
/bin/csh
Program Function:
fd = creat("/etc/shells", 0755);
f_write = fopen("/etc/shells", "a+"
;
fputs("/bin/sh", f_write);
fputs("/bin/csh", f-write);
fputs("/bin/ksh", f_write);
Second Question:
I want to append char's on a line where I can add to the end of it. Example
before:
ftp inet
after:
ftp inet +1 -U
wrong:What I don't want it to do
/bin/sh/bin/ksh/bin/csh
right:What I want it to do
/bin/sh
/bin/ksh
/bin/csh
Program Function:
fd = creat("/etc/shells", 0755);
f_write = fopen("/etc/shells", "a+"
fputs("/bin/sh", f_write);
fputs("/bin/csh", f-write);
fputs("/bin/ksh", f_write);
Second Question:
I want to append char's on a line where I can add to the end of it. Example
before:
ftp inet
after:
ftp inet +1 -U