C program to copy values from double pointer array into file
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
void func(char **envp)
{
FILE *fp = NULL;
fp = fopen
("dhcp", "w");
if (fp == NULL){
printf("failed to open %s", "dhcp");
return ;
}
int i = 0;
while(envp[i] !=
NULL) {
fwrite( envp[i], strlen(envp[i])+1, 1, fp);
i++;
}
fclose(fp);
}
int main()
{
char *envp[] =
{"stallone\0" ,"google\0", NULL };
func(&envp[0]);
return 0;
}