| 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | |||||||||
| 10 | 1 | 1 | 1 | |||||||
| 20 | 1 | 1 | ||||||||
| 30 | 1 | 1 | ||||||||
| 40 | 2 | 1 | ||||||||
| 50 | ||||||||||
| 60 | 2 | 1 | 1 | 1 | ||||||
| 70 | 2 | 1 | ||||||||
| 80 | 1 | |||||||||
| 90 | 1 | 1 | ||||||||
| Totals | 4 | 4 | 3 | 2 | 2 | 3 | 0 | 2 | 1 | 1 |
| 000 | 100 | 200 | 300 | 400 | |
|---|---|---|---|---|---|
| 0 | 1 | ||||
| 10 | |||||
| 20 | |||||
| 30 | 2 | 2 | |||
| 40 | 2 | ||||
| 50 | 1 | 1 | 1 | ||
| 60 | 3 | 1 | 2 | ||
| 70 | 1 | ||||
| 80 | 1 | 1 | 1 | ||
| 90 | 1 | 1 | |||
| Totals | 5 | 6 | 4 | 6 | 1 |
| total | pages per procedure | |||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| procs | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 1 | 1 | |||||||||||||||||
| 1 | 1 | |||||||||||||||||
| 1 | 1 | |||||||||||||||||
| 2 | 1 | 1 | ||||||||||||||||
| 2 | 1 | 1 | ||||||||||||||||
| 2 | 1 | 1 | ||||||||||||||||
| 4 | 3 | 1 | ||||||||||||||||
| 5 | 2 | 1 | 1 | 1 | ||||||||||||||
| 6 | 2 | 2 | 1 | 1 | ||||||||||||||
| 6 | 3 | 2 | 1 | |||||||||||||||
| 7 | 5 | 2 | ||||||||||||||||
| 7 | 6 | 1 | ||||||||||||||||
| 8 | 4 | 2 | 2 | |||||||||||||||
| 8 | 6 | 1 | 1 | |||||||||||||||
| 9 | 4 | 2 | 1 | 2 | ||||||||||||||
| 14 | 9 | 2 | 3 | |||||||||||||||
| 15 | 12 | 3 | ||||||||||||||||
| 18 | 13 | 2 | 2 | 1 | ||||||||||||||
| 19 | 16 | 2 | 1 | |||||||||||||||
| 39 | 31 | 4 | 1 | 2 | 1 | |||||||||||||
| 46 | 45 | 1 | ||||||||||||||||
int main(int argc, char * argv[]) {
char * title = argv[1];
ifstream infile(title, ios::in);
if (!infile) {
// blah blah blah
}
i = 0;
ifstream fin2("int.txt", ios::in);
while(!fin2.eof()) {
fin2.getline(tem1[i], 255, '\n');
// blah blah blah
i++;
}
enum enum_type_for_chars { CHARACTERS, VAR };
typedef enum_type_for_chars ETFC;
How about enum char_type { CHARACTERS, VAR };
char ** pattern = new char*[5000]; char ** pat_without_spc = new char*[5000]; char ** tem = new char* [5000]; char ** tem1 = new char* [5000]; char ** rep = new char* [5000]; for (int i = 0; i < 5000; i++) for (int k = 0 ; k < 5000; k++)
void CharToMatchText(char ch) {
char* Temp;
int Length = 0;
Length = strlen(match_text);
Temp = new char[Length+1];
Temp[0] = '\0';
strcpy(Temp, match_text);
Temp[Length] = '\0';
delete [] match_text;
match_text = new char[Length+2];
match_text[0] = '\0';
strcpy(match_text, Temp);
match_text[Length] = ch;
match_text[Length+1] = '\0';
}
|
void CharToReplacementText(char ch) {
char* Temp;
int Length = 0;
Length = strlen(replc_text);
Temp = new char[Length+1];
Temp[0] = '\0';
strcpy(Temp, replc_text);
Temp[Length] = '\0';
delete [] replc_text;
replc_text = new char[Length+2];
replc_text[0] = '\0';
strcpy(replc_text, Temp);
replc_text[Length] = ch;
replc_text[Length+1] = '\0';
}
|
void CharToInterText(char ch) {
char* Temp;
int Length = 0;
Length = strlen(inter_text);
Temp = new char[Length+1];
Temp[0] = '\0';
strcpy(Temp, inter_text);
Temp[Length] = '\0';
delete [] inter_text;
inter_text = new char[Length+2];
inter_text[0] = '\0';
strcpy(inter_text, Temp);
inter_text[Length] = ch;
inter_text[Length+1] = '\0';
}
|
void CharToInText(char ch) {
char* Temp;
int Length = 0;
Length = strlen(in_text);
Temp = new char[Length+1];
Temp[0] = '\0';
strcpy(Temp, in_text);
Temp[Length] = '\0';
delete [] in_text;
in_text = new char[Length+2];
in_text[0] = '\0';
strcpy(in_text, Temp);
in_text[Length] = ch;
in_text[Length+1] = '\0';
}
|
| vs | |
void CharToMatchText(char ch) {
CharToText(match_text, ch);
}
void CharToReplacementText(char ch) {
CharToText(replc_text, ch);
}
void CharToInterText(char ch) {
CharToText(inter_text, ch);
}
void CharToInText(char ch) {
CharToText(in_text, ch);
}
|
void CharToText(char * & text, char ch) {
char* Temp;
int Length = 0;
Length = strlen(text);
Temp = new char[Length+1];
Temp[0] = '\0';
strcpy(Temp, text);
Temp[Length] = '\0';
delete [] text;
text = new char[Length+2];
text[0] = '\0';
strcpy(text, Temp);
text[Length] = ch;
text[Length+1] = '\0';
}
|
Don't Use
Compare
char * Strings
void optimize::CharToMatchText(char ch) {
char* Temp;
int Length = 0;
Length = strlen(match_text);
Temp = new char[Length+1];
Temp[0] = '\0';
strcpy(Temp, match_text);
Temp[Length] = '\0';
delete [] match_text;
match_text = new char[Length+2];
match_text[0] = '\0';
strcpy(match_text, Temp);
match_text[Length] = ch;
match_text[Length+1] = '\0';
}
to
void optimize::CharToMatchText(char ch) {
match_text += ch;
}
FILE * imc;
imc = fopen(argv[2], "r");
while (fgets(line, 80, imc)) {
if (isspace(line[0])) continue;
line[strlen(line) - 1] = NULL;
imc_temp->inter_line = (char *) malloc (strlen(line));
strcpy(imc_temp->inter_line, line);
argv[2] exists? Should it exist?fopen() succeed or fail?NULL?malloc() return?strcpy() doing?
ifstream patternFile( argv[1], ios::in);
while (!patternFile.eof()) {
patternFile >> pattern;
// blah blah blah
}
if ((code[0] = '-') & (code[1] >='0') && (code[1] >= '9')) {
code = pattern;
return 1;
}
if ((code[0] >= '0' && code[0] <= '9') && (pattern[0] == '$')) {
code = pattern;
return 1;
}
How about
if (((code[0] = '-') && isdigit(code[1])) || {
(isdigit(code[0]) && (pattern[0] == '$'))) {
code = pattern;
return 1;
}
Sometimes Even Strings Don't Help
string match_result;
match_result_length=match_result.length();
for (int check103 = 0; check103 <= match_result_length; check103++) {
if ((match_result[check103] >= 65) && (match_result[check103] <= 90)) {
// whatever
}
else
output_result += match_result[check103];
}
bool readInst(List *L, char *&inst, int noInst) {
char * line = new char[80];
inst = new char[80];
strcpy(inst, "\0");
line = L->getNext();
if ( line == NULL ) {
inst = NULL;
return false;
}
// blah blah blah
}
This page last modified on 27 March 2001.