Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
11 years ago

Why none getchar(), getc, fgetc() work ?

I built a embedded system in qsys which has the jtag_uart IP. Based on default set,jtag_uart is used as stdin, stdout. I create a hello world project and it can print hello world in console.

But after I added the command like:

getchar(), getc(), or fgetc(), then the program can't be build. It reports errors like: "undefined reference to 'getc' ". I copy my codes as below:

# include <stdio.h># include "..\hello_world_bsp\HAL\inc\io.h"# include "..\hello_world_bsp\system.h"

typedef unsigned int uint;

int main()

{

printf("Hello from Nios II!\n");

int c;

c= getc(stdin);

//c=getchar();

printf("This is from UART: %d", c);

return 0;

}

I also attached the screenshot. Why these functions which use jtag_uart to read don't work? Do I missed to include any files?

Thanks in advance.