14.2.2 Simple Output
Once a file has been opened for writing a string can be written to the file using the fputs
function. The following example shows how to write the string ‘Free Software is needed for Free Science’ to the file ‘free.txt’.
filename = "free.txt"; fid = fopen (filename, "w"); fputs (fid, "Free Software is needed for Free Science"); fclose (fid);
- fputs (fid, string)
- status = fputs (fid, string)
-
Write the string string to the file with file descriptor fid.
The string is written to the file with no additional formatting. Use
fdisp
instead to automatically append a newline character appropriate for the local machine.Return a non-negative number on success or EOF on error.
A function much similar to fputs
is available for writing data to the screen. The puts
function works just like fputs
except it doesn’t take a file pointer as its input.
- puts (string)
- status = puts (string)
-
Write a string to the standard output with no formatting.
The string is written verbatim to the standard output. Use
disp
to automatically append a newline character appropriate for the local machine.Return a non-negative number on success and EOF on error.
© 1996–2020 John W. Eaton
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://octave.org/doc/v5.2.0/Simple-Output.html