Created
March 18, 2023 14:30
-
-
Save rk76feWF/3a6122be3b493671f9adec901fa3dc52 to your computer and use it in GitHub Desktop.
prints関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void prints(const char *format, ...) | |
{ | |
va_list args; | |
va_start(args, format); | |
int length = vsnprintf(NULL, 0, format, args) + 1; | |
char buffer[length]; | |
vsnprintf(buffer, length, format, args); | |
for (int i = 0; i < length - 1; i++) | |
{ | |
while (U2STAbits.TRMT == 0) | |
; | |
U2TXREG = buffer[i]; | |
} | |
va_end(args); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
xc16ではmalloc関数を使いたい場合、ヒープサイズの指定が必要っぽい。VLAなら問題なく使用できる。