Name: Anonymous 2008-07-19 16:14
Ok /prog/, Lets write a program.
I'll start.
I'll start.
#include <iostream>
#include <iostream>
#error No.
int main ()
{
printf("The only way to make C++ tolerable is to use it to write in C.\n");
#undef return
return EXIT_SUCCESS;
}
putStrLn "How did I get here I am not good with C++"
void HaxAnus(std::Anus anus)
{
anus.Hax();
}
system that I mentioned above is a system that I defined myself and it uses proper UNIX etiquette. I undefined the other default system call.
#include <cstring>
#include <fstream>
#include <sstream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include "../../C03/8/WordIterator.cpp"
using namespace std;
void myPrintLn(string s) {
cout << s << endl;
}
bool isWord(const char* s) {
const size_t len = strlen(s);
size_t i = 0;
while(i++ < len && isalpha(s[i]));
return i == len;
}
int main(int argc, const char** argv) {
// Check if we've been given enough arguments
if(argc < 3) {
cout << "Usage: " << argv[0] << " <file_path> <word1> <word2> ..."
<< endl;
return 0;
}
// Open the input file specified as the first argument
ifstream file(argv[1]);
if(file.fail()) {
cout << "Error: Could not open file \"" << argv[1] << "\"" << endl;
return 0;
}
// Open the output file
ofstream outfile(string(argv[1]).append(".matches").c_str());
if(outfile.fail()) {
cout << "Error: Could not open output file \"" << argv[1]
<< ".matches\"" << endl;
return 0;
}
// Here we will store words_sought given on the command line
typedef set<string> sset;
typedef vector<const char*> svector;
sset words_sought;
svector args;
args.reserve(argc - 2);
copy(argv + 2, argv + argc, back_inserter(args));
// Check if all arguments are proper words
svector::iterator bad_args = partition(args.begin(), args.end(),
ptr_fun(isWord));
// Some arguments contain characters not in the standard alphabet
if(bad_args != args.end()) {
cout << "These arguments are not words:" << endl;
for_each(bad_args, args.end(), ptr_fun(myPrintLn));
cout << "Continuing without them" << endl;
}
// Gather the rest of the arguments
copy(args.begin(), bad_args, inserter(words_sought, words_sought.begin()));
args.resize(0); // We won't need this anymore
istringstream line_stream;
string line;
size_t line_nr = 1;
const WIT eoi;
while(getline(file, line)) {
line_stream.str(line);
WIT word(line_stream);
/* Search for matches word-by-word. Stop at the first match or
* end-of-input
*/
while(word != eoi && words_sought.find(*word) == words_sought.end())
++word;
// Match! Print the whole line
if(word != eoi) {
outfile << line_nr << ' ' << line << endl;
}
++line_nr;
}
return 0;
}
int x = flaming_rabid_shrew_cast<int>(new float(5.0f));