| Message |
Eh, I haven't done a lot of code for reading from files, so I ran into a problem. I want to read from a file and store it in the account data. (account->character) But I don't want the character files to be written to, only read. Here's what I have so far:
D_CHAR *load_character(char *player)
{
FILE *fp;
D_CHAR *character = NULL;
char cfile[256];
char cName[20];
int size, i;
cName[0] = toupper(player[0]);
size = strlen(player);
for (i = 1; i < size; i++)
cName[i] = tolower(player[i]);
cName[i] = '\0';
sprintf(cfile, "../chars/%s.char", cName);
if ((fp = fopen(cfile, "r")) == NULL)
return NULL;
fclose(fp);
return character;
}
In the select cmd:
if ((load_character(arg)) == NULL)
{
act_send(act, "No such char.\n\r");
return;
}
Everything returns NULL though.
In the main header file, in the account strut:
In the main header file (in diff parts):
typedef struct character D_CHAR;
struct character
{
char * name;
char * skill;
};
D_CHAR *load_character ( char *character);
So want I want it to do, is when an account selects a character, it loads the char file to account->character, and something like account->character->name will work. |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | top |
|