Python
with open("log.txt") as infile:
for line in infile:
do_something_with(line)
C
#include <stdio.h>
main()
{
FILE *fp;
fp = fopen("/tmp/test.txt", "w+");
fprintf(fp, "This is testing for fprintf ...\n");
fputs("This is testing for fputs...\n", fp);
fclose(fp);
}
C++
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream MyFile("filename.txt");
MyFile << "Files can be tricky, but it is fun enough!";
MyFile.close();
}