본문 바로가기
C 언어

putenv

by SpeeDr00t 2016. 7. 9.
반응형

int putenv(const char *str)



#include <stdlib.h>
#include <string.h>

int
putenv(const char *str)
{
	char *p, *equal;
	int rval;

	if ((p = strdup(str)) == NULL)
		return (-1);
	if ((equal = strchr(p, '=')) == NULL) {
		(void)free(p);
		return (-1);
	}
	*equal = '\0';
	rval = setenv(p, equal + 1, 1);
	(void)free(p);
	return (rval);
}
반응형

'C 언어' 카테고리의 다른 글

heapsort  (0) 2016.07.09
malloc  (0) 2016.07.09
realpath  (0) 2016.07.09
random  (0) 2016.07.09
setenv  (0) 2016.07.09