int main(void)
{
uint8_t Str[80] = {0};
SZ_STM32_COMInit();
while(1)
{
scanf("%s", Str);
printf(&quot;\n\r 输入的字符串是: <%s>\n&quot;, Str);
}
}
int fputc(int ch, FILE *f)
{
/* e.g. write a character to the USART */
USART_SendData(USART1, (uint8_t) ch);
/* Loop until the end of transmission */
while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);
return ch;
}
int fgetc(FILE *f)
{
int ch = 0;
while(USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET);
ch = (int)USART1->DR & 0xFF;
putchar(ch); //回显
return ch;
}
我是这样编写的,但是编译出错。
..\Output\STM32-DEMO.axf: Error: L6218E: Undefined symbol __vfscanf_char_file (referred from __0scanf.o).
..\Output\STM32-DEMO.axf: Not enough information to list image symbols.
..\Output\STM32-DEMO.axf: Finished: 1 information, 0 warning and 1 error messages. |