H
Hilary Cotter
Thanks for all the help you gave me yesterday.
here is another question.
I have a comma delimited file called redirect.txt which looks like
this
test, /test.htm
test 123,/test123.htm
I am reading these values and processing them, but it seems like the
way I am doing it is not efficient. I was hoping for pointers on how
to make this more efficient.
// testparse.cpp : Defines the entry point for the console
application.
//
#include "stdafx.h"
//#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <ctype.h>
int main(int argc, char* argv[])
{
FILE *fp;
int i;
struct test
{
char in[100];
char out[100];
} my_test [150];
fp =fopen("c:\\Redirect.txt", "r");
if (!fp)
{
printf ("Can't open test file!\n");
return 1;
}
i=0;
while ((fscanf(fp, "%[a-z \\.] %[a-z \\.,]", &my_test.in)) !=
EOF)
{
fgetc(fp);
fscanf(fp, "%s", &my_test.out);
fgetc(fp);
printf("in %s out %s\n",my_test.in, my_test.out);
++i;
}
fclose( fp);
return 0;
}
here is another question.
I have a comma delimited file called redirect.txt which looks like
this
test, /test.htm
test 123,/test123.htm
I am reading these values and processing them, but it seems like the
way I am doing it is not efficient. I was hoping for pointers on how
to make this more efficient.
// testparse.cpp : Defines the entry point for the console
application.
//
#include "stdafx.h"
//#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <ctype.h>
int main(int argc, char* argv[])
{
FILE *fp;
int i;
struct test
{
char in[100];
char out[100];
} my_test [150];
fp =fopen("c:\\Redirect.txt", "r");
if (!fp)
{
printf ("Can't open test file!\n");
return 1;
}
i=0;
while ((fscanf(fp, "%[a-z \\.] %[a-z \\.,]", &my_test.in)) !=
EOF)
{
fgetc(fp);
fscanf(fp, "%s", &my_test.out);
fgetc(fp);
printf("in %s out %s\n",my_test.in, my_test.out);
++i;
}
fclose( fp);
return 0;
}