Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Produce a functionally identical PHP code for the snippet given in REXX.
options replace format comments java crossref symbols nobinary import java.text.DateFormat edate = Date(0) zulu = DateFormat.getDateTimeInstance() zulu.setTimeZone(TimeZone.getTimeZone('UTC')) say zulu.format(edate) return
<?php echo gmdate('r', 0), "\n"; ?>
Can you help me rewrite this code in PHP instead of Ruby, keeping it the same logically?
irb(main):001:0> Time.at(0).utc => 1970-01-01 00:00:00 UTC
<?php echo gmdate('r', 0), "\n"; ?>
Translate this program into PHP but keep the logic exactly as in Ruby.
irb(main):001:0> Time.at(0).utc => 1970-01-01 00:00:00 UTC
<?php echo gmdate('r', 0), "\n"; ?>
Convert the following code from Scala to PHP, ensuring the logic remains intact.
import java.util.Date import java.util.TimeZone import java.text.DateFormat fun main( args: Array<String>) { val epoch = Date(0) val format = DateFormat.getDateTimeInstance() format.timeZone = TimeZone.getTimeZone("UTC") println(format.format(epoch)) }
<?php echo gmdate('r', 0), "\n"; ?>
Preserve the algorithm and functionality while converting the code from Scala to PHP.
import java.util.Date import java.util.TimeZone import java.text.DateFormat fun main( args: Array<String>) { val epoch = Date(0) val format = DateFormat.getDateTimeInstance() format.timeZone = TimeZone.getTimeZone("UTC") println(format.format(epoch)) }
<?php echo gmdate('r', 0), "\n"; ?>
Change the following C code into Rust without altering its purpose.
#include <time.h> #include <stdio.h> int main() { time_t t = 0; printf("%s", asctime(gmtime(&t))); return 0; }
extern crate time; use time::{at_utc, Timespec}; fn main() { let epoch = at_utc(Timespec::new(0, 0)); println!("{}", epoch.asctime()); }
Write the same code in Rust as shown below in C++.
#include <iostream> #include <chrono> #include <ctime> int main() { std::chrono::system_clock::time_point epoch; std::time_t t = std::chrono::system_clock::to_time_t(epoch); std::cout << std::asctime(std::gmtime(&t)) << '\n'; return 0; }
extern crate time; use time::{at_utc, Timespec}; fn main() { let epoch = at_utc(Timespec::new(0, 0)); println!("{}", epoch.asctime()); }
Port the provided C++ code into Rust while preserving the original functionality.
#include <iostream> #include <chrono> #include <ctime> int main() { std::chrono::system_clock::time_point epoch; std::time_t t = std::chrono::system_clock::to_time_t(epoch); std::cout << std::asctime(std::gmtime(&t)) << '\n'; return 0; }
extern crate time; use time::{at_utc, Timespec}; fn main() { let epoch = at_utc(Timespec::new(0, 0)); println!("{}", epoch.asctime()); }
Please provide an equivalent version of this C# code in Rust.
using System; class Program { static void Main() { Console.WriteLine(new DateTime()); } }
extern crate time; use time::{at_utc, Timespec}; fn main() { let epoch = at_utc(Timespec::new(0, 0)); println!("{}", epoch.asctime()); }
Produce a functionally identical Rust code for the snippet given in C#.
using System; class Program { static void Main() { Console.WriteLine(new DateTime()); } }
extern crate time; use time::{at_utc, Timespec}; fn main() { let epoch = at_utc(Timespec::new(0, 0)); println!("{}", epoch.asctime()); }
Ensure the translated Rust code behaves exactly like the original Java snippet.
import java.text.DateFormat; import java.util.Date; import java.util.TimeZone; public class DateTest{ public static void main(String[] args) { Date date = new Date(0); DateFormat format = DateFormat.getDateTimeInstance(); format.setTimeZone(TimeZone.getTimeZone("UTC")); System.out.p...
extern crate time; use time::{at_utc, Timespec}; fn main() { let epoch = at_utc(Timespec::new(0, 0)); println!("{}", epoch.asctime()); }
Produce a language-to-language conversion: from Rust to Python, same semantics.
extern crate time; use time::{at_utc, Timespec}; fn main() { let epoch = at_utc(Timespec::new(0, 0)); println!("{}", epoch.asctime()); }
>>> import time >>> time.asctime(time.gmtime(0)) 'Thu Jan 1 00:00:00 1970' >>>
Write a version of this Rust function in VB with identical behavior.
extern crate time; use time::{at_utc, Timespec}; fn main() { let epoch = at_utc(Timespec::new(0, 0)); println!("{}", epoch.asctime()); }
Sub Main() Debug.Print Format(0, "dd mmm yyyy hh:mm") End Sub
Please provide an equivalent version of this Rust code in VB.
extern crate time; use time::{at_utc, Timespec}; fn main() { let epoch = at_utc(Timespec::new(0, 0)); println!("{}", epoch.asctime()); }
Sub Main() Debug.Print Format(0, "dd mmm yyyy hh:mm") End Sub
Rewrite this program in Rust while keeping its functionality equivalent to the Java version.
import java.text.DateFormat; import java.util.Date; import java.util.TimeZone; public class DateTest{ public static void main(String[] args) { Date date = new Date(0); DateFormat format = DateFormat.getDateTimeInstance(); format.setTimeZone(TimeZone.getTimeZone("UTC")); System.out.p...
extern crate time; use time::{at_utc, Timespec}; fn main() { let epoch = at_utc(Timespec::new(0, 0)); println!("{}", epoch.asctime()); }
Port the following code from C to Rust with equivalent syntax and logic.
#include <time.h> #include <stdio.h> int main() { time_t t = 0; printf("%s", asctime(gmtime(&t))); return 0; }
extern crate time; use time::{at_utc, Timespec}; fn main() { let epoch = at_utc(Timespec::new(0, 0)); println!("{}", epoch.asctime()); }
Write a version of this Go function in Rust with identical behavior.
package main import ("fmt"; "time") func main() { fmt.Println(time.Time{}) }
extern crate time; use time::{at_utc, Timespec}; fn main() { let epoch = at_utc(Timespec::new(0, 0)); println!("{}", epoch.asctime()); }
Port the following code from Go to Rust with equivalent syntax and logic.
package main import ("fmt"; "time") func main() { fmt.Println(time.Time{}) }
extern crate time; use time::{at_utc, Timespec}; fn main() { let epoch = at_utc(Timespec::new(0, 0)); println!("{}", epoch.asctime()); }
Change the programming language of this snippet from Rust to Python without modifying what it does.
extern crate time; use time::{at_utc, Timespec}; fn main() { let epoch = at_utc(Timespec::new(0, 0)); println!("{}", epoch.asctime()); }
>>> import time >>> time.asctime(time.gmtime(0)) 'Thu Jan 1 00:00:00 1970' >>>
Rewrite the snippet below in C# so it works the same as the original Ada code.
with Ada.Directories; use Ada.Directories; with Ada.Text_IO; use Ada.Text_IO; procedure Test_File_Size is begin Put_Line (File_Size'Image (Size ("input.txt")) & " bytes"); Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes"); end Test_File_Size;
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Rewrite this program in C while keeping its functionality equivalent to the Ada version.
with Ada.Directories; use Ada.Directories; with Ada.Text_IO; use Ada.Text_IO; procedure Test_File_Size is begin Put_Line (File_Size'Image (Size ("input.txt")) & " bytes"); Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes"); end Test_File_Size;
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Convert this Ada snippet to C++ and keep its semantics consistent.
with Ada.Directories; use Ada.Directories; with Ada.Text_IO; use Ada.Text_IO; procedure Test_File_Size is begin Put_Line (File_Size'Image (Size ("input.txt")) & " bytes"); Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes"); end Test_File_Size;
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Convert this Ada block to Go, preserving its control flow and logic.
with Ada.Directories; use Ada.Directories; with Ada.Text_IO; use Ada.Text_IO; procedure Test_File_Size is begin Put_Line (File_Size'Image (Size ("input.txt")) & " bytes"); Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes"); end Test_File_Size;
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Rewrite the snippet below in Java so it works the same as the original Ada code.
with Ada.Directories; use Ada.Directories; with Ada.Text_IO; use Ada.Text_IO; procedure Test_File_Size is begin Put_Line (File_Size'Image (Size ("input.txt")) & " bytes"); Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes"); end Test_File_Size;
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Convert this Ada block to Python, preserving its control flow and logic.
with Ada.Directories; use Ada.Directories; with Ada.Text_IO; use Ada.Text_IO; procedure Test_File_Size is begin Put_Line (File_Size'Image (Size ("input.txt")) & " bytes"); Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes"); end Test_File_Size;
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Port the following code from Ada to VB with equivalent syntax and logic.
with Ada.Directories; use Ada.Directories; with Ada.Text_IO; use Ada.Text_IO; procedure Test_File_Size is begin Put_Line (File_Size'Image (Size ("input.txt")) & " bytes"); Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes"); end Test_File_Size;
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Transform the following Arturo implementation into C, maintaining the same output and logic.
print volume "input.txt" print volume "/input.txt"
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Write the same algorithm in C# as shown in this Arturo implementation.
print volume "input.txt" print volume "/input.txt"
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Preserve the algorithm and functionality while converting the code from Arturo to C++.
print volume "input.txt" print volume "/input.txt"
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Produce a language-to-language conversion: from Arturo to Java, same semantics.
print volume "input.txt" print volume "/input.txt"
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Ensure the translated Python code behaves exactly like the original Arturo snippet.
print volume "input.txt" print volume "/input.txt"
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Change the programming language of this snippet from Arturo to VB without modifying what it does.
print volume "input.txt" print volume "/input.txt"
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Transform the following Arturo implementation into Go, maintaining the same output and logic.
print volume "input.txt" print volume "/input.txt"
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Port the provided AutoHotKey code into C while preserving the original functionality.
FileGetSize, FileSize, input.txt   MsgBox, Size of input.txt is %FileSize% bytes FileGetSize, FileSize, \input.txt, K   MsgBox, Size of \input.txt is %FileSize% Kbytes
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Generate a C# translation of this AutoHotKey snippet without changing its computational steps.
FileGetSize, FileSize, input.txt   MsgBox, Size of input.txt is %FileSize% bytes FileGetSize, FileSize, \input.txt, K   MsgBox, Size of \input.txt is %FileSize% Kbytes
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Convert this AutoHotKey block to C++, preserving its control flow and logic.
FileGetSize, FileSize, input.txt   MsgBox, Size of input.txt is %FileSize% bytes FileGetSize, FileSize, \input.txt, K   MsgBox, Size of \input.txt is %FileSize% Kbytes
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Translate the given AutoHotKey code snippet into Java without altering its behavior.
FileGetSize, FileSize, input.txt   MsgBox, Size of input.txt is %FileSize% bytes FileGetSize, FileSize, \input.txt, K   MsgBox, Size of \input.txt is %FileSize% Kbytes
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Write the same code in Python as shown below in AutoHotKey.
FileGetSize, FileSize, input.txt   MsgBox, Size of input.txt is %FileSize% bytes FileGetSize, FileSize, \input.txt, K   MsgBox, Size of \input.txt is %FileSize% Kbytes
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Please provide an equivalent version of this AutoHotKey code in VB.
FileGetSize, FileSize, input.txt   MsgBox, Size of input.txt is %FileSize% bytes FileGetSize, FileSize, \input.txt, K   MsgBox, Size of \input.txt is %FileSize% Kbytes
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Rewrite the snippet below in Go so it works the same as the original AutoHotKey code.
FileGetSize, FileSize, input.txt   MsgBox, Size of input.txt is %FileSize% bytes FileGetSize, FileSize, \input.txt, K   MsgBox, Size of \input.txt is %FileSize% Kbytes
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Convert this AWK snippet to C and keep its semantics consistent.
@load "filefuncs" function filesize(name ,fd) { if ( stat(name, fd) == -1) return -1 else return fd["size"] } BEGIN { print filesize("input.txt") print filesize("/input.txt") }
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Transform the following AWK implementation into C#, maintaining the same output and logic.
@load "filefuncs" function filesize(name ,fd) { if ( stat(name, fd) == -1) return -1 else return fd["size"] } BEGIN { print filesize("input.txt") print filesize("/input.txt") }
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Can you help me rewrite this code in C++ instead of AWK, keeping it the same logically?
@load "filefuncs" function filesize(name ,fd) { if ( stat(name, fd) == -1) return -1 else return fd["size"] } BEGIN { print filesize("input.txt") print filesize("/input.txt") }
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Transform the following AWK implementation into Java, maintaining the same output and logic.
@load "filefuncs" function filesize(name ,fd) { if ( stat(name, fd) == -1) return -1 else return fd["size"] } BEGIN { print filesize("input.txt") print filesize("/input.txt") }
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Change the programming language of this snippet from AWK to Python without modifying what it does.
@load "filefuncs" function filesize(name ,fd) { if ( stat(name, fd) == -1) return -1 else return fd["size"] } BEGIN { print filesize("input.txt") print filesize("/input.txt") }
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Change the following AWK code into VB without altering its purpose.
@load "filefuncs" function filesize(name ,fd) { if ( stat(name, fd) == -1) return -1 else return fd["size"] } BEGIN { print filesize("input.txt") print filesize("/input.txt") }
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Please provide an equivalent version of this AWK code in Go.
@load "filefuncs" function filesize(name ,fd) { if ( stat(name, fd) == -1) return -1 else return fd["size"] } BEGIN { print filesize("input.txt") print filesize("/input.txt") }
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Rewrite the snippet below in C so it works the same as the original BBC_Basic code.
file% = OPENIN(@dir$+"input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF file% = OPENIN("\input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Convert this BBC_Basic snippet to C# and keep its semantics consistent.
file% = OPENIN(@dir$+"input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF file% = OPENIN("\input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Translate this program into C++ but keep the logic exactly as in BBC_Basic.
file% = OPENIN(@dir$+"input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF file% = OPENIN("\input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Produce a language-to-language conversion: from BBC_Basic to Java, same semantics.
file% = OPENIN(@dir$+"input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF file% = OPENIN("\input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Maintain the same structure and functionality when rewriting this code in Python.
file% = OPENIN(@dir$+"input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF file% = OPENIN("\input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Change the following BBC_Basic code into VB without altering its purpose.
file% = OPENIN(@dir$+"input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF file% = OPENIN("\input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Port the provided BBC_Basic code into Go while preserving the original functionality.
file% = OPENIN(@dir$+"input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF file% = OPENIN("\input.txt") IF file% THEN PRINT "File size = " ; EXT#file% CLOSE #file% ENDIF
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Convert this Clojure snippet to C and keep its semantics consistent.
(require '[clojure.java.io :as io]) (defn show-size [filename] (println filename "size:" (.length (io/file filename)))) (show-size "input.txt") (show-size "/input.txt")
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Translate the given Clojure code snippet into C# without altering its behavior.
(require '[clojure.java.io :as io]) (defn show-size [filename] (println filename "size:" (.length (io/file filename)))) (show-size "input.txt") (show-size "/input.txt")
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Produce a language-to-language conversion: from Clojure to C++, same semantics.
(require '[clojure.java.io :as io]) (defn show-size [filename] (println filename "size:" (.length (io/file filename)))) (show-size "input.txt") (show-size "/input.txt")
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Convert the following code from Clojure to Java, ensuring the logic remains intact.
(require '[clojure.java.io :as io]) (defn show-size [filename] (println filename "size:" (.length (io/file filename)))) (show-size "input.txt") (show-size "/input.txt")
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Port the following code from Clojure to Python with equivalent syntax and logic.
(require '[clojure.java.io :as io]) (defn show-size [filename] (println filename "size:" (.length (io/file filename)))) (show-size "input.txt") (show-size "/input.txt")
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Translate this program into VB but keep the logic exactly as in Clojure.
(require '[clojure.java.io :as io]) (defn show-size [filename] (println filename "size:" (.length (io/file filename)))) (show-size "input.txt") (show-size "/input.txt")
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Write the same algorithm in Go as shown in this Clojure implementation.
(require '[clojure.java.io :as io]) (defn show-size [filename] (println filename "size:" (.length (io/file filename)))) (show-size "input.txt") (show-size "/input.txt")
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Convert this Common_Lisp snippet to C and keep its semantics consistent.
(with-open-file (stream (make-pathname :name "input.txt") :direction :input :if-does-not-exist nil) (print (if stream (file-length stream) 0))) (with-open-file (stream (make-pathname :directory '(:absolute "") :name "input.txt") :direction :input ...
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Write the same algorithm in C# as shown in this Common_Lisp implementation.
(with-open-file (stream (make-pathname :name "input.txt") :direction :input :if-does-not-exist nil) (print (if stream (file-length stream) 0))) (with-open-file (stream (make-pathname :directory '(:absolute "") :name "input.txt") :direction :input ...
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Generate an equivalent C++ version of this Common_Lisp code.
(with-open-file (stream (make-pathname :name "input.txt") :direction :input :if-does-not-exist nil) (print (if stream (file-length stream) 0))) (with-open-file (stream (make-pathname :directory '(:absolute "") :name "input.txt") :direction :input ...
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Convert this Common_Lisp snippet to Java and keep its semantics consistent.
(with-open-file (stream (make-pathname :name "input.txt") :direction :input :if-does-not-exist nil) (print (if stream (file-length stream) 0))) (with-open-file (stream (make-pathname :directory '(:absolute "") :name "input.txt") :direction :input ...
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Change the programming language of this snippet from Common_Lisp to Python without modifying what it does.
(with-open-file (stream (make-pathname :name "input.txt") :direction :input :if-does-not-exist nil) (print (if stream (file-length stream) 0))) (with-open-file (stream (make-pathname :directory '(:absolute "") :name "input.txt") :direction :input ...
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Change the following Common_Lisp code into VB without altering its purpose.
(with-open-file (stream (make-pathname :name "input.txt") :direction :input :if-does-not-exist nil) (print (if stream (file-length stream) 0))) (with-open-file (stream (make-pathname :directory '(:absolute "") :name "input.txt") :direction :input ...
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Transform the following Common_Lisp implementation into Go, maintaining the same output and logic.
(with-open-file (stream (make-pathname :name "input.txt") :direction :input :if-does-not-exist nil) (print (if stream (file-length stream) 0))) (with-open-file (stream (make-pathname :directory '(:absolute "") :name "input.txt") :direction :input ...
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Convert this D block to C, preserving its control flow and logic.
import std.file, std.stdio, std.path, std.file, std.stream, std.mmfile; void main() { immutable fileName = "file_size.exe"; try { writefln("File '%s' has size:", fileName); writefln("%10d bytes by std.file.getSize (function)", std.file.getSize(fileName)); writ...
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Ensure the translated C# code behaves exactly like the original D snippet.
import std.file, std.stdio, std.path, std.file, std.stream, std.mmfile; void main() { immutable fileName = "file_size.exe"; try { writefln("File '%s' has size:", fileName); writefln("%10d bytes by std.file.getSize (function)", std.file.getSize(fileName)); writ...
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Convert this D block to C++, preserving its control flow and logic.
import std.file, std.stdio, std.path, std.file, std.stream, std.mmfile; void main() { immutable fileName = "file_size.exe"; try { writefln("File '%s' has size:", fileName); writefln("%10d bytes by std.file.getSize (function)", std.file.getSize(fileName)); writ...
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Convert this D snippet to Java and keep its semantics consistent.
import std.file, std.stdio, std.path, std.file, std.stream, std.mmfile; void main() { immutable fileName = "file_size.exe"; try { writefln("File '%s' has size:", fileName); writefln("%10d bytes by std.file.getSize (function)", std.file.getSize(fileName)); writ...
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Convert the following code from D to Python, ensuring the logic remains intact.
import std.file, std.stdio, std.path, std.file, std.stream, std.mmfile; void main() { immutable fileName = "file_size.exe"; try { writefln("File '%s' has size:", fileName); writefln("%10d bytes by std.file.getSize (function)", std.file.getSize(fileName)); writ...
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Transform the following D implementation into VB, maintaining the same output and logic.
import std.file, std.stdio, std.path, std.file, std.stream, std.mmfile; void main() { immutable fileName = "file_size.exe"; try { writefln("File '%s' has size:", fileName); writefln("%10d bytes by std.file.getSize (function)", std.file.getSize(fileName)); writ...
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Translate the given D code snippet into Go without altering its behavior.
import std.file, std.stdio, std.path, std.file, std.stream, std.mmfile; void main() { immutable fileName = "file_size.exe"; try { writefln("File '%s' has size:", fileName); writefln("%10d bytes by std.file.getSize (function)", std.file.getSize(fileName)); writ...
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Keep all operations the same but rewrite the snippet in C.
program SizeOfFile; uses SysUtils; function CheckFileSize(const aFilename: string): Integer; var lFile: file of Byte; begin AssignFile(lFile, aFilename); FileMode := 0; Reset(lFile); Result := FileSize(lFile); CloseFile(lFile); end; begin Writeln('input.txt ', CheckFileSize('input.txt')); Writeln(...
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Generate a C# translation of this Delphi snippet without changing its computational steps.
program SizeOfFile; uses SysUtils; function CheckFileSize(const aFilename: string): Integer; var lFile: file of Byte; begin AssignFile(lFile, aFilename); FileMode := 0; Reset(lFile); Result := FileSize(lFile); CloseFile(lFile); end; begin Writeln('input.txt ', CheckFileSize('input.txt')); Writeln(...
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Change the following Delphi code into C++ without altering its purpose.
program SizeOfFile; uses SysUtils; function CheckFileSize(const aFilename: string): Integer; var lFile: file of Byte; begin AssignFile(lFile, aFilename); FileMode := 0; Reset(lFile); Result := FileSize(lFile); CloseFile(lFile); end; begin Writeln('input.txt ', CheckFileSize('input.txt')); Writeln(...
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Generate an equivalent Java version of this Delphi code.
program SizeOfFile; uses SysUtils; function CheckFileSize(const aFilename: string): Integer; var lFile: file of Byte; begin AssignFile(lFile, aFilename); FileMode := 0; Reset(lFile); Result := FileSize(lFile); CloseFile(lFile); end; begin Writeln('input.txt ', CheckFileSize('input.txt')); Writeln(...
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Convert this Delphi block to Python, preserving its control flow and logic.
program SizeOfFile; uses SysUtils; function CheckFileSize(const aFilename: string): Integer; var lFile: file of Byte; begin AssignFile(lFile, aFilename); FileMode := 0; Reset(lFile); Result := FileSize(lFile); CloseFile(lFile); end; begin Writeln('input.txt ', CheckFileSize('input.txt')); Writeln(...
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Change the following Delphi code into VB without altering its purpose.
program SizeOfFile; uses SysUtils; function CheckFileSize(const aFilename: string): Integer; var lFile: file of Byte; begin AssignFile(lFile, aFilename); FileMode := 0; Reset(lFile); Result := FileSize(lFile); CloseFile(lFile); end; begin Writeln('input.txt ', CheckFileSize('input.txt')); Writeln(...
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Rewrite this program in Go while keeping its functionality equivalent to the Delphi version.
program SizeOfFile; uses SysUtils; function CheckFileSize(const aFilename: string): Integer; var lFile: file of Byte; begin AssignFile(lFile, aFilename); FileMode := 0; Reset(lFile); Result := FileSize(lFile); CloseFile(lFile); end; begin Writeln('input.txt ', CheckFileSize('input.txt')); Writeln(...
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Convert the following code from Elixir to C, ensuring the logic remains intact.
IO.puts File.stat!("input.txt").size IO.puts File.stat!("/input.txt").size
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Port the following code from Elixir to C# with equivalent syntax and logic.
IO.puts File.stat!("input.txt").size IO.puts File.stat!("/input.txt").size
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Translate the given Elixir code snippet into C++ without altering its behavior.
IO.puts File.stat!("input.txt").size IO.puts File.stat!("/input.txt").size
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Preserve the algorithm and functionality while converting the code from Elixir to Java.
IO.puts File.stat!("input.txt").size IO.puts File.stat!("/input.txt").size
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Preserve the algorithm and functionality while converting the code from Elixir to Python.
IO.puts File.stat!("input.txt").size IO.puts File.stat!("/input.txt").size
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Convert this Elixir snippet to VB and keep its semantics consistent.
IO.puts File.stat!("input.txt").size IO.puts File.stat!("/input.txt").size
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Change the following Elixir code into Go without altering its purpose.
IO.puts File.stat!("input.txt").size IO.puts File.stat!("/input.txt").size
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Write the same code in C as shown below in Erlang.
-module(file_size). -export([file_size/0]). -include_lib("kernel/include/file.hrl"). file_size() -> print_file_size("input.txt"), print_file_size("/input.txt"). print_file_size(Filename) -> case file:read_file_info(Filename) of {ok, FileInfo} -> io:format("~s ~p~n", [Filename, FileInfo#file_info.si...
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Convert this Erlang block to C#, preserving its control flow and logic.
-module(file_size). -export([file_size/0]). -include_lib("kernel/include/file.hrl"). file_size() -> print_file_size("input.txt"), print_file_size("/input.txt"). print_file_size(Filename) -> case file:read_file_info(Filename) of {ok, FileInfo} -> io:format("~s ~p~n", [Filename, FileInfo#file_info.si...
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Generate an equivalent C++ version of this Erlang code.
-module(file_size). -export([file_size/0]). -include_lib("kernel/include/file.hrl"). file_size() -> print_file_size("input.txt"), print_file_size("/input.txt"). print_file_size(Filename) -> case file:read_file_info(Filename) of {ok, FileInfo} -> io:format("~s ~p~n", [Filename, FileInfo#file_info.si...
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Rewrite the snippet below in Java so it works the same as the original Erlang code.
-module(file_size). -export([file_size/0]). -include_lib("kernel/include/file.hrl"). file_size() -> print_file_size("input.txt"), print_file_size("/input.txt"). print_file_size(Filename) -> case file:read_file_info(Filename) of {ok, FileInfo} -> io:format("~s ~p~n", [Filename, FileInfo#file_info.si...
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }
Generate an equivalent Python version of this Erlang code.
-module(file_size). -export([file_size/0]). -include_lib("kernel/include/file.hrl"). file_size() -> print_file_size("input.txt"), print_file_size("/input.txt"). print_file_size(Filename) -> case file:read_file_info(Filename) of {ok, FileInfo} -> io:format("~s ~p~n", [Filename, FileInfo#file_info.si...
import os size = os.path.getsize('input.txt') size = os.path.getsize('/input.txt')
Generate an equivalent VB version of this Erlang code.
-module(file_size). -export([file_size/0]). -include_lib("kernel/include/file.hrl"). file_size() -> print_file_size("input.txt"), print_file_size("/input.txt"). print_file_size(Filename) -> case file:read_file_info(Filename) of {ok, FileInfo} -> io:format("~s ~p~n", [Filename, FileInfo#file_info.si...
Option Explicit ---- Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String) Dim i As Long If InStr(Len(Path), Path, "\") = 0 Then Path = Path & "\" End If On Error Resume Next i = FileLen(Path & Filename) If Err.Number = 0 Then Debug.Print "file size: " & CStr(i) & " Bytes" Else ...
Generate a Go translation of this Erlang snippet without changing its computational steps.
-module(file_size). -export([file_size/0]). -include_lib("kernel/include/file.hrl"). file_size() -> print_file_size("input.txt"), print_file_size("/input.txt"). print_file_size(Filename) -> case file:read_file_info(Filename) of {ok, FileInfo} -> io:format("~s ~p~n", [Filename, FileInfo#file_info.si...
package main import "fmt" import "os" func printFileSize(f string) { if stat, err := os.Stat(f); err != nil { fmt.Println(err) } else { fmt.Println(stat.Size()) } } func main() { printFileSize("input.txt") printFileSize("/input.txt") }
Can you help me rewrite this code in C instead of F#, keeping it the same logically?
open NUnit.Framework open FsUnit [<Test>] let ``Validate that the size of the two files is the same`` () = let local = System.IO.FileInfo(__SOURCE_DIRECTORY__ + "\input.txt") let root = System.IO.FileInfo(System.IO.Directory.GetDirectoryRoot(__SOURCE_DIRECTORY__) + "input.txt") local.Length = root.Length |> shou...
#include <stdlib.h> #include <stdio.h> long getFileSize(const char *filename) { long result; FILE *fh = fopen(filename, "rb"); fseek(fh, 0, SEEK_END); result = ftell(fh); fclose(fh); return result; } int main(void) { printf("%ld\n", getFileSize("input.txt")); printf("%ld\n", getFileSize("/input.txt"))...
Write the same code in C# as shown below in F#.
open NUnit.Framework open FsUnit [<Test>] let ``Validate that the size of the two files is the same`` () = let local = System.IO.FileInfo(__SOURCE_DIRECTORY__ + "\input.txt") let root = System.IO.FileInfo(System.IO.Directory.GetDirectoryRoot(__SOURCE_DIRECTORY__) + "input.txt") local.Length = root.Length |> shou...
using System; using System.IO; class Program { static void Main(string[] args) { Console.WriteLine(new FileInfo("/input.txt").Length); Console.WriteLine(new FileInfo("input.txt").Length); } }
Can you help me rewrite this code in C++ instead of F#, keeping it the same logically?
open NUnit.Framework open FsUnit [<Test>] let ``Validate that the size of the two files is the same`` () = let local = System.IO.FileInfo(__SOURCE_DIRECTORY__ + "\input.txt") let root = System.IO.FileInfo(System.IO.Directory.GetDirectoryRoot(__SOURCE_DIRECTORY__) + "input.txt") local.Length = root.Length |> shou...
#include <iostream> #include <fstream> std::ios::off_type getFileSize(const char *filename) { std::ifstream f(filename); std::ios::pos_type begin = f.tellg(); f.seekg(0, std::ios::end); std::ios::pos_type end = f.tellg(); return end - begin; } int main() { std::cout << getFileSize("input.txt") << std::end...
Write the same algorithm in Java as shown in this F# implementation.
open NUnit.Framework open FsUnit [<Test>] let ``Validate that the size of the two files is the same`` () = let local = System.IO.FileInfo(__SOURCE_DIRECTORY__ + "\input.txt") let root = System.IO.FileInfo(System.IO.Directory.GetDirectoryRoot(__SOURCE_DIRECTORY__) + "input.txt") local.Length = root.Length |> shou...
import java.io.File; public class FileSize { public static void main ( String[] args ) { System.out.println("input.txt  : " + new File("input.txt").length() + " bytes"); System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes"); } }