#include <string> // this is bad and we will eventually remove this using namespace std; // this function removes all non alphabetic characters from a string string StripString(string line);
#ifndef SOME_VARIABLE_NAME
#define SOME_VARIABLE_NAME
//code goes here
#endif
#ifndef DANS_STRING_UTILS #define DANS_STRING_UTILS #include <string> // this is bad and we will eventually remove this using namespace std; // this function removes all non alphabetic characters from a string string StripString(string line); #endif
#include <iostream>
// this is good practice
#include "StringUtils.h"
// because we will remove it from the .h file
using namespace std;
// notice this matches the function prototype just like before
string StripString(string line) {
size_t i;
string rv;
for(i=0;i<line.size();i++) {
if (isalpha(line[i])) {
rv += line[i];
}
}
return rv;
}
#include <iostream>
#include <fstream>
#include "StringUtils.h"
using namespace std;
while (file and dictionarySize < MAX_WORDS) {
dictionary[dictionarySize] = StripString(word);
g++ -g -O3 -Wall -Wextra -Wuninitialized -pedantic -Wshadow -Weffc++ -Wunused -c -o StringUtils.o StringUtils.C
g++ -g -O3 -Wall -Wextra -Wuninitialized -pedantic -Wshadow -Weffc++ -Wunused dictionary.C StringUtils.o -o dictionary
CXXFLAGS = -g -O3 -Wall -Wextra -Wuninitialized -pedantic -Wshadow -Weffc++ -Wunused
all: dictionary
dictionary: StringUtils.o
StringUtils.o: StringUtils.h
clean:
rm -rf dictionary *.o