Re: PLEASE Help Me With Simple C++ Code!
I like C...
<font class="small">Code:</font><hr /><pre>#include <string.h>
#include <stdio.h>
void main(int argc, char *argv[])
{
FILE *f;
int found = 0;
char *position;
char line[300];
f = fopen(argv[1], "r");
while (fgets(line, sizeof(line), f)) {
position = line;
while (position = strstr(position++, "hate me")) {
found++;
}
}
fclose(f);
printf ("\"hate me\" found %d times.\n", found);
}</pre><hr />
|