I just started learning c recently, and im trying to put it to 'good' use by writing a small program that can take a string of words and numbers and sort them into a struct array, heres what Ive come up with so far:
The delimitor section in the main essentially breaks the string up into seperate tokens (I think thats what theyre called?). The names might be a bit odd but its not for a MUD or anything inparticular, I just like rpgsCode:
char delTester ="Shadow Knight,Dark Elf,15";
delimiter = strtok(delTester, ",");
while (delimiter != NULL)
delimiter = strtok(NULL, ",");
printf("players class is: %s\n", RPGStructTester.PlayerClass);
Anyway my problem is after the deliminator has broken the string into seperate tokens (comma is used as the delimitor)., I cant figure out how to pass the values of each token into the struct Rpgstruct.
I know I need to use strcpy to copy each individual token into the corresponding struct data entry, but I just cant figure it out, and couldnt find any online guides on something so specific.
I guess I just really dont know the syntax etc of c yet.
But if anyone could give me a hand in the right direction I'd really appreciate it