两层指针的参数

#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;
}
posted @ 2017-07-23 15:20  苏小北1024  阅读(365)  评论(0编辑  收藏  举报