使用过高级语言如C++, Python, Java的程序员对这种异常处理机制应该经常见到:
FileReader fr = null; try { File file = new File("file.txt"); fr = new FileReader(file); char [] a = new char[50]; fr.read(a); // reads the content to the array for(char c : a) System.out.print(c); // prints the characters one by one } catch (IOException e) { e.printStackTrace(); }finally { try { fr.close(); } catch (IOException ex) { ex.printStackTrace(); } }
但是C语言并没有这种try catch的机制, 达到类似的效果, 可以使用
setjmp/longjmp两个函数, 本贴使用xmc1100开发板介绍一下这两个函数.
只有注册用户才能在此添加评论。 如果您已经注册,请登录。 如果您还没有注册,请注册并登录。