音影先锋亚洲天堂网|电影世界尽头的爱完整版播放|国产 熟女 91|高清无码免费观看欧美日韩|韩国一区二区三区黄色录像|美女亚洲加勒比在线|亚洲综合网 开心五月|7x成人在线入口|成人网站免费日韩毛片区|国产黄片?一级?二级?三级

登錄 免費注冊 首頁 | 行業(yè)黑名單 | 幫助
維庫電子市場網(wǎng)
技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng)
驅(qū)動編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機 | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計 | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe

Keil 官方技術(shù)支持集<絕對經(jīng)典>

作者:leeding 欄目:單片機
Keil 官方技術(shù)支持集<絕對經(jīng)典>
包含了使用Keil的方方面面的問題.
這里資料怎么上傳。?

如:
C51: '\N' DOES NOT WORK IN PRINTF() STATEMENTS

--------------------------------------------------------------------------------

Information in this SUPPORT solution applies to:


C51 Version 5.50
C51 Version 6.00 Beta
C51 Version 6.00

--------------------------------------------------------------------------------


SYMPTOMS

It appears that my \n does not work in printf() statements. When I view the OUTPUT on a DUMB terminal, I do not see a carriage return-LINE feed. For example:

printf("hello world\n");


The above statement does not appear to send the '\n'. Instead, I have to use this to make it work:

printf("hello world");
putchar(CR);


Why does this happen? What is printf doing to the '\n'?


CAUSE

In most C compilers, including ours, the newLINE escape sequence '\n' yields an ASCII LINE feed character. The C escape sequence for a carriage return is '\r'.

When you create C programs in what the C STANDARD calls a "hosted implementation" (where the programs run under an operating SYSTEM), the operating SYSTEM or the stdio library routines are supposed to convert the newLINE character to whatever it takes to actually go to the beginning of the next LINE, e.g., carriage return + LINE feed.

For a "freestanding implementation" (where the programs run without any operating SYSTEM), the STANDARD doesn't specify any requirements for library routines. It is up to the compiler vendor to decide what library routines to provide, and how each should work. All Keil compilers are freestanding implementations of C.

Users of our compilers send the OUTPUT from printf() to a variety of devices with different requirements for MARKING the end of a LINE. So, any method we might choose to handle '\n' would be wrong in many cases.

On OUTPUT, the default version of our library routine putchar() handles newLINE characters by OUTPUTting a carriage return and a LINE feed. Many projects require a user-written version of putchar(). If your project has a CUSTOM putchar() function, it may handle newLINE characters differently. For example, it may pass all characters through with no special-case treatment for '\n' (LINE feed).


RESOLUTION

There are three different ways to solve this problem:

Include a '\r' along with (or perhaps instead of) the '\n' in OUTPUT strings.

printf("Hello world\r\n");


Modify the putchar() function such that when it is called to OUTPUT a LINE feed, it OUTPUTs a carriage return in addition to the LINE feed.

Use a terminal that will treat a LINE feed character as a newLINE character (i.e., as a carriage return and LINE feed).






--------------------------------------------------------------------------------

Last Reviewed: 5/26/2000
COPYRIGHT (c) 1996-1999 Keil SOFTWARE, Inc. All rights reserved.

2樓: >>參與討論
john_light
到這里,更全更新
http://www.keil.com/search.asp
你說的那個文件應(yīng)該是keil的光盤上帶的support.chm。

參與討論
昵稱:
討論內(nèi)容:
 
 
相關(guān)帖子
請教MSC1210單片機與計算機串口通信的問題
Keil C51程序的HEX文件超過了3K,我能優(yōu)化到2K以下嗎?
農(nóng)講所的"狀態(tài)機"和HOTPOWER的"前后臺".誰能簡單給概括一下思想
一條指令多少錢?
請問一下用C寫片子要掌握哪些基本的數(shù)據(jù)結(jié)構(gòu)
免費注冊為維庫電子開發(fā)網(wǎng)會員,參與電子工程師社區(qū)討論,點此進入


Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號