io1: Add printf examples
Signed-off-by: Louis Solofrizzo <lsolofrizzo@online.net>
This commit is contained in:
parent
4cf27f5081
commit
e7c0133eac
2 changed files with 28 additions and 0 deletions
3
unikernel-demo/io1/printf/Makefile
Normal file
3
unikernel-demo/io1/printf/Makefile
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export ukl-obj-m := main.o
|
||||||
|
|
||||||
|
include ../../Makefile
|
||||||
25
unikernel-demo/io1/printf/main.c
Normal file
25
unikernel-demo/io1/printf/main.c
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifndef USERSPACE
|
||||||
|
#define main ukl_main
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char a;
|
||||||
|
char *b;
|
||||||
|
int c;
|
||||||
|
} test_t;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
char str[250];
|
||||||
|
test_t test = {
|
||||||
|
.a = 'a',
|
||||||
|
.b = "Hello!",
|
||||||
|
.c = 10
|
||||||
|
};
|
||||||
|
|
||||||
|
printf("a = %c, b = %s, c = %d\n", test.a, test.b, test.c);
|
||||||
|
snprintf(str, sizeof(str), "a = %c, b = %s, c = %d\n", test.a, test.b, test.c);
|
||||||
|
puts(str);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue