Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void _getenv(const char *name)
- {
- int count = 0, cmp = 0, size = 0;
- char *copy;
- const char del[] = "=";
- char *token;
- copy = strdup(name);
- size = strlen(name);
- size++;
- while (environ[count])
- {
- /* get the first token */
- token = strtok(environ[count], del);
- /* walk through other tokens */
- while (token != NULL)
- {
- cmp = strcmp(token, copy);
- if (cmp == 0)
- {
- if (token)
- {
- token = strtok(token + size, ":");
- while (token != NULL)
- {
- printf("%s\n", token);
- token = strtok(NULL, ":");
- }
- }
- }
- token = strtok(NULL, del);
- }
- count++;
- }
- }
- int main(void)
- {
- const char *name = "PATH";
- _getenv(name);
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement