|
发表于 2021-9-22 12:14:25
|
显示全部楼层
string.h
- #ifndef _STRING_H_
- #define _STRING_H_
- void put_string(char code);
- #endif
复制代码
string.c
- #include "string.h"
- #include <stdio.h>
- static const char *value(size_t index) {
- static const char *string[] = {
- "1234",
- "qwer",
- "hello"
- };
- return string[index];
- }
- void put_string(char code) {
- if(code == '1') printf("%s\n", value(0));
- else if(code == 'q') printf("%s\n", value(1));
- else if(code == 'h') printf("%s\n", value(2));
- }
复制代码
main.c
- #include "string.h"
- int main(void) {
- put_string('1');
- put_string('h');
- return 0;
- }
复制代码 |
|