chsrc/helper.h

33 lines
719 B
C
Raw Normal View History

2023-08-28 22:21:14 +08:00
/* --------------------------------------------------------------
* File : helper.h
* Authors : Aoran Zeng <ccmywish@qq.com>
* Created on : <2023-08-28>
2023-08-29 15:54:21 +08:00
* Last modified : <2023-08-29>
2023-08-28 22:21:14 +08:00
*
* helper:
*
* helper functions and macros
* -------------------------------------------------------------*/
#include <string.h>
#include <stdlib.h>
2023-08-29 21:58:51 +08:00
#ifdef _WIN32
#include <windows.h>
#define xy_useutf8() SetConsoleOutputCP(65001)
#else
#define xy_useutf8()
#endif
2023-08-28 22:21:14 +08:00
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
char*
2023-08-29 15:54:21 +08:00
xy_strjoin (const char* str1, const char* str2)
2023-08-28 22:21:14 +08:00
{
size_t len = strlen(str1) + strlen(str2) + 1;
char* ret = malloc(len);
strcat(ret, str1);
strcat(ret, str2);
return ret;
}