From 08af426f01cf0321719c937d29a1d9315a0feab8 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sun, 7 Mar 2021 08:34:04 +0800 Subject: [example] 格式化整理 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/libc/printf.c | 58 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'examples/libc/printf.c') diff --git a/examples/libc/printf.c b/examples/libc/printf.c index 2d2d8a7763..85e33671d6 100644 --- a/examples/libc/printf.c +++ b/examples/libc/printf.c @@ -142,59 +142,59 @@ int printf_test() int i; printf ("snprintf (\"%%30s\", \"foo\") == %d, \"%.*s\"\n", - snprintf (buf, sizeof (buf), "%30s", "foo"), (int) sizeof (buf), - buf); + snprintf (buf, sizeof (buf), "%30s", "foo"), (int) sizeof (buf), + buf); memset(buf2,0,sizeof(buf)); i=snprintf(buf2, 256, "%.9999u", 10); printf("%i %i\n",i,strlen(buf2)); printf ("snprintf (\"%%.999999u\", 10) == %d\n", - snprintf(buf2, sizeof(buf2), "%.999999u", 10)); + snprintf(buf2, sizeof(buf2), "%.999999u", 10)); } return 0; } void libc_printf() { - printf("stdout test!!\n"); - fprintf(stdout, "fprintf test!!\n"); - fprintf(stderr, "fprintf test!!\n"); - puts("puts test!!\n"); + printf("stdout test!!\n"); + fprintf(stdout, "fprintf test!!\n"); + fprintf(stderr, "fprintf test!!\n"); + puts("puts test!!\n"); - putc('1', stderr); - putc('2', stderr); - putc('\n', stderr); + putc('1', stderr); + putc('2', stderr); + putc('\n', stderr); - printf_test(); + printf_test(); } FINSH_FUNCTION_EXPORT(libc_printf, printf test in libc); void libc_dprintf() { - int fd; - - fd = open("/dev/console", O_WRONLY, 0); - if (fd >0) - { - dprintf(fd, "fd:%d printf test!!\n", fd); - close(fd); - } + int fd; + + fd = open("/dev/console", O_WRONLY, 0); + if (fd >0) + { + dprintf(fd, "fd:%d printf test!!\n", fd); + close(fd); + } } FINSH_FUNCTION_EXPORT(libc_dprintf, dprintf test); void libc_fdopen() { - int fd; - FILE* fp; - - fd = open("/dev/console", O_WRONLY, 0); - if (fd >0) - { - fp = fdopen(fd, "w"); - fprintf(fp, "fdopen test, fd %d!!\n", fileno(fp)); - fclose(fp); - } + int fd; + FILE* fp; + + fd = open("/dev/console", O_WRONLY, 0); + if (fd >0) + { + fp = fdopen(fd, "w"); + fprintf(fp, "fdopen test, fd %d!!\n", fileno(fp)); + fclose(fp); + } } FINSH_FUNCTION_EXPORT(libc_fdopen, fdopen test); -- cgit v1.3.1