> > What? He asked for a program and I gave him one. Not a very good one,
but
it would work. No-one else even bothered to write one.
Really? My example can beat up your example. :-)
-Mike
Sorry, yes, you're right as a general program. But if he just wants to count
between those two particular directives then mine'll be easier for him to
use. I'll just fix it for commandline input, but that was chapter...actua lly
it wasn't in C for dummies at all.
Maybe this should be used as an example of how not to code whilst still
getting a working program.
#include <stdio.h>
char filepath[100];
char tstr[10];
int lines;
FILE* cfile
int main(int whatever, char**notaclue) {
lines=0
if(whatever==1) goto meaninglesslabe l;
printf("I didn't understand the arguments you gave me, so what's the file
then?\n");
gets(filepath);
goto evenworse;
meaninglesslabe l: filepath=notacl ue[1];//or should this be 0? I never really
//worked out how the ags are arranged
evenworse:
cfile=fopen(fil epath, "r");
fseek(cfile,SEE K_SET);//not sure if this is correctly formulated
for(;strcmp(tst r,"#ifdef win32")!=0;fget s(cfile,tstr));//value for strcmp
//may be wrong, fgets args may also be wrong
for(;strcmp(tst r,"#endif")!=0; fgets(cfile,tst r)) lines++;
printf("There were %d lines between the pre-processor commands\n",lin es);
//is this how you want it returned?
return lines; //or return 0;
}