P
pkirk25
I wonder if anyone has time to write a small example program based on
this data or to critique my own effort?
A file called Realm List.html contains the following data:
Bladefist-Horde
Nordrassil-Horde
Draenor-Alliance
Nordrassil-Alliance
Nordrassil-Neutral
Draenor-Horde
Moonglade-Horde
Shadowmoon-Horde
Moonglade-Alliance
I need an algorithm that takes from this list the names of Realms that
we have both Alliance and Horde data for and to list them in
alphabetical order. My desired format of this list will be:
Draenor-Alliance
Draenor-Horde
Moonglade-Alliance
Moonglade-Horde
Nordrassil-Alliance
Nordrassil-Horde
I'm committed to using ANSI C with the K&R book as my guide. It says a
string is an array of chars.
Right now I can open the file, I can use strtok to split each line but
I can't work out how to create an array of these strings?
FILE *realmList;
if((realmList=fopen("Realm List.html","w+")) == NULL)
{
printf("Couldn't open \"Realm List.html\" for output\n");
return 1;
}
/*
List Realms and count of each
*/
char strLine[244];
while (fgets(strLine, 244, realmList))
{
char *tmp = NULL;
char token[] = "-";
tmp = strtok(strLine, token);
printf("%s\n", tmp);
/* stuck at this point */
}
this data or to critique my own effort?
A file called Realm List.html contains the following data:
Bladefist-Horde
Nordrassil-Horde
Draenor-Alliance
Nordrassil-Alliance
Nordrassil-Neutral
Draenor-Horde
Moonglade-Horde
Shadowmoon-Horde
Moonglade-Alliance
I need an algorithm that takes from this list the names of Realms that
we have both Alliance and Horde data for and to list them in
alphabetical order. My desired format of this list will be:
Draenor-Alliance
Draenor-Horde
Moonglade-Alliance
Moonglade-Horde
Nordrassil-Alliance
Nordrassil-Horde
I'm committed to using ANSI C with the K&R book as my guide. It says a
string is an array of chars.
Right now I can open the file, I can use strtok to split each line but
I can't work out how to create an array of these strings?
FILE *realmList;
if((realmList=fopen("Realm List.html","w+")) == NULL)
{
printf("Couldn't open \"Realm List.html\" for output\n");
return 1;
}
/*
List Realms and count of each
*/
char strLine[244];
while (fgets(strLine, 244, realmList))
{
char *tmp = NULL;
char token[] = "-";
tmp = strtok(strLine, token);
printf("%s\n", tmp);
/* stuck at this point */
}