How Do I?
Q. How can I read a file into a string?Use Stdio.read_file():
Q. How can a I write a string to a file?Use Stdio.write_file():
// read the contents of foo.txt into variable s. // If the file doesn't exist or could not be read, s will be set to 0 (zero). string s = Stdio.read_file("foo.txt");
// write the contents of variable s into foo.txt (replacing any existing contents). // the variable x will be set to the number of bytes written to the file. // If the file doesn't exist or could not be could not be written, x will be set to 0 (zero). string s = "some text"; int x = Stdio.write_file("foo.txt", s);
Powered by PikeWiki2
|gotpike.org | Copyright © 2004 - 2009 | Pike is a trademark of Department of Computer and Information Science, Linköping University|