两层指针的参数
#cat redirect.h
#ifndef REDIRECT_PTR_H
#define REDIRECT_PTR_H
extern void get_a_day(const char **);
#endif
#cat redirect.c
#include "redirect_prt.h"
static const char *msg[] = {
"Sunday","Monday","Tuesday","Thursday","Friday","Saturday"
};
void get_a_day(const char **pp){
static int i = 0;
*pp = msg[i%7];
i++;
}
#cat main.c
#include <stdio.h>
#include "redirect.h"
int main(void){
const char *firstday = NULL;
const char *secondday = NULL;
get_a_day(&firstday);
get_a_day(&secondday);
printf("%s\t%s\n",firstday,secondday);
return 0;
}
muahao@aliyun.com