Category Archives: C++

C++ Read from a file using fstream

/** Read from a file (version 1) Copyright 2009 Travis Crowder travis.crowder@spechal.com Published under the MIT License */ #include <iostream> #include <fstream> #include <string> int main(int argc, char* argv[]){ // create the file handle, opening the file std::fstream myFile("text.txt", std::ios::in); … Continue reading

Posted in C++ | Tagged | Leave a comment

C++ Write to a file using fstream

/** Write to a file (version 1) Copyright 2009 Travis Crowder travis.crowder@spechal.com Published under the MIT License */ #include <iostream> #include <fstream> int main(int argc, char* argv[]){ // create the file handle, opening the file as well std::fstream myFile("text.txt", std::ios::out); … Continue reading

Posted in C++ | Leave a comment

C++ Palindrome Checker

/** Palindrome Checker Copyright 2009 Travis Crowder Published under the MIT License */ #include <iostream> #include <algorithm> #include <string> bool isPalindrome(const std::string theWord); int main(int argc, char* argv[]){ std::string theWord; if(!argv[1]){ std::cout << "Enter the word to check: "; std::cin … Continue reading

Posted in C++ | Tagged | Leave a comment

C++ Guessing Game

/** Guessing Game Copyright 2009 Travis Crowder travis.crowder@spechal.com Published under the MIT License */ #include <iostream> int main(int argc, char* argv[]){ /** Create our variable to hold the guess made */ int guess = 0; /** Let’s keep track of … Continue reading

Posted in C++ | Leave a comment