007
17.06.2003, 17:36 Uhr
arkantos
|
Meine Lösung ist zwar n bisschen aufwendig, aber sie funktioniert:
C++: |
#include <stdio.h> #include <string.h>
main(int argc, char *argv[]) { const char* cpp_keywords[] = { "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break", "case", "catch", "char", "class", "compl", "const", "const_cast", "continue", "default", "delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", "float", "for", "friend", "goto", "if", "inline", "int", "long", "mutable", "namespace", "new", "not", "not_eq", "operator", "or", "or_eq", "private", "protected", "public", "register", "reinterpret_cast", "return", "short", "switch", "template", "this", "throw", "true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using", "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq" };
FILE *fp, *poi; char wort[30]; int i, j; char line1;
fp=fopen(argv[1], "r"); poi=fopen("ausgabe", "w+");
if(fp==NULL) {printf("fp ist NULL\n"); exit(11);}
/*Sonderzeichen, Strings, includes werden rausgefischt*/ while(feof(fp)==0) { line1=fgetc(fp);
if(line1=='"') while(1) { line1=fgetc(fp); if(line1=='"') break; }
if(line1=='#') while(1) { line1=fgetc(fp); if(line1=='\n') break; }
if(toupper(line1)>=0x41 && toupper(line1)<=0x5A) {fputc(line1, poi);} else { if(line1=='\n') fputc(line1, poi); else if(line1=='_') fputc('_', poi); else fputc(' ', poi); }
}
fclose(fp); rewind(poi);
/*Schlüsselwörter werden rausgefischt*/
while(feof(poi)==0) { fscanf(poi, "%s", wort);
for(i=0; i<69; i++) { if(strcmp(wort, cpp_keywords[i])==0) {break;} else; } if(i==69) printf("%s\n", wort);
}
fclose(poi); }
|
-- schöne grüße, arkantos Dieser Post wurde am 17.06.2003 um 17:37 Uhr von arkantos editiert. |