The procedure is as follows
#include <stdio.h> #include <string.h> #include "system.h" int main () { char* msg = "detected the character ' t '. \ n"; file* fp; char prompt = 0; printf ("Please enter some characters: \n "); fp = fopen ("/dev/uart_0 ", " r+ "); //open file for read and write if (FP) { while (prompt != ' V ') // Loop until receiving ' V ' { prompt = GETC (FP); // get character if from Jtag uart (prompt == ' t ') { // if the character is ' t ' Print Info fwrite (msg, strlen (msg), &NBSP;1,&NBSP;FP) ; } if (Ferror (FP))// Check if the error appears with the file pointer clearerr (FP);// If yes, clear it } fprintf (fp, "Closing the UART file handle.\n "); fclose (FP); } else { printf ("fail to open file...\n"); }return 0;} error is as follows wrong reason for detailed connection address http://www.altera.com.cn/support/kdb/solutions/rd10152012_873.html
Undefined reference to ' fclose ' errors occurred while doing Nios II uart232 experiments.