Jump to content

Rename a file: Difference between revisions

Ada solution added
(Ada solution added)
Line 3:
In this task, the job is to rename the file called "input.txt" into "output.txt" and a directory called "docs" into "mydocs". This should be done twice: once "here", i.e. in the current working directory and once in the filesystem root.
 
=={{header|Ada}}==
<lang ada>
with Ada.Directories; use Ada.Directories;
...
Rename ("input.txt", "output.txt");
Rename ("docs", "mydocs");
Rename ("/input.txt", "/output.txt");
Rename ("/docs", "/mydocs");
</lang>
The behavior depends on the concrete [[OS | operating system]] regarding:
* file name encoding issues;
* file path notation (directory separator, directory syntax etc);
* file extension syntax;
* file system root (provided there is any).
=={{header|C}}==
{{works with|gcc|4.1.2 20061115 (prerelease) (SUSE Linux)}}
Cookies help us deliver our services. By using our services, you agree to our use of cookies.