Unix类型
#include "system.h"
#include "fcntl.h"
#include "unistd.h"
int main(void)
{
int fd; // file descriptor
char msg[] = "Hello Nios!";
fd = open("/dev/jtag_uart", O_WRONLY);
write(fd, msg, sizeof(msg)-1);
close(fd);
return 0;
}
Info: (hello_nios.elf) 2608 Bytes program size (code + initialized data).
Info: 8189 KBytes free for stack + heap.
ANSI C
#include "system.h"
#include <stdio.h>
int main (void)
{
FILE *fp; // file pointer
char msg[] = "Hello Nios!";
fp = fopen("/dev/jtag_uart", "w");
fprintf(fp, msg);
fclose(fp);
return 0;
}
Info: (hello_nios.elf) 43 KBytes program size (code + initialized data).
Info: 8148 KBytes free for stack + heap.
文章评论(0条评论)
登录后参与讨论