Subscribe to thetrh51        RSS Feed
-----

back from break, well sort of...

Icon Leave Comment
So I have been taking a break from posting and writing in C++, and switched to python. Unless you are using C or C++ for a reason, then you should switch too, and here is why...

Python: 60 seconds
#document reader for python 2.7 in windows
import os
fname = raw_input("Please enter a file name: ")
os.system("cls")
file1 = open(fname, "r+b")
fileinput = file1.read()
print fileinput



C++: 4 minutes
#include <iostream>
#include <cstdlib>
#include <string>
#include <fstream>

using namespace std;

int main()
{
cout << "Enter a file name to read: ";
string fname
cin >> fname;
system("cls");
ifstream readfile;
readfile.open(fname);
string data;
readfile >> data;
cout << data;
}



Witch one did you think took longer to write?

LOL,
-Tristan

0 Comments On This Entry

 

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

July 2014

S M T W T F S
  12345
6789101112
13141516171819
20212223242526
27 28 293031  

Tags

    Recent Entries

    Search My Blog

    1 user(s) viewing

    1 Guests
    0 member(s)
    0 anonymous member(s)

    Categories