So I am fooling around with strchr
to get part of a string from a file:
void manipulateComputers(char *name)
{
name[strlen(name)-2] = '\0';
printf("%s\n", name);
char *ptr = strchr(name, ' ');
printf("%s\n", ptr);
}
At the first printf
it reads:
zelda 1 flux 1 hydra 1 willow 1 swift 1 aeon 1 neptune 1
At the second printf
it reads:
1 flux 1 hydra 1 willow 1 swift 1 aeon 1 neptune 1
As you can see, the zelda
is gone, which is kind of what I wanted to do. I wanted to remove the zelda
, but now I want to use zelda
.
Essentially, I wanted the second printf
to print just zelda
and not the string without zelda
.
How do I get a hold of that zelda
to eventually pass it to another function. Thanks