A Tutorial Introduction

Let us begin with a quick introduction in C.

The only way to learn a new programming language is by writing programs in it.

Now, for some explanations about the program itself. A C program, whatever its size, consists of functions and variables. A function contains statements that specify the computing operations to be done, and variables store values used during the computation.C functions are like the subroutines and functions in Fortran or the procedures and functions of Pascal. Our example is a function named "main". Normally you are at liberty to give functions whatever names you like, but "main" is special---your program begins executing at the beginning of "main". This means that every program must have a "main" somewhere. And "main" will usually call other functions to help perform its job, some that you wrote, and other from libraries that are provided for you. The first line of the program, "#include <stdio.h>" tells the compiler to include information about the standard input/output library; the line appears at beginning of many C source files. The standard library is described in Chapter & and Appendix B.

One method of communicating data between functions is for the calling function to provide a list of values, called arguments, to the function it calls. The parentheses after the function name surround the argument list. In this example, "main" is defined to be a function that expects no arguments, which is indicated by the emptylist ().

#include <stdio.h>

main ()

{

??? printf("hello, world\n");

}

The statements of a function are enclosed in braces {}. The function "main" contains only one statement, "printf("hello, world\n");".

The function 'printf" is a library function that prints output, in this case the string of characters between the quotes. A sequence of charaaters in double quotes, like "hello world\n", is called a character string or string constant.

轉(zhuǎn)義字符:在C語(yǔ)言中龟劲,用反斜線字符“\”作為轉(zhuǎn)義字符肾扰,來(lái)表示那些不可打印的ASCII控制符璧亮。

\a: alter(bell) character

\b: backspace

\f: formfeed

\n: newline

\r: carriage return

\t: horizontal tab

\v: vertical tab

\\: backslash

\?: question mark

\': single quote

\": double quote

\ooo octal number-\ddd 1~3 位八進(jìn)制數(shù)所代表的字符

\xhh: hexadecimal number--\xhh 1~2 位十六進(jìn)制數(shù)所代表的字符


We recommended writing only one statement per line, and using blanks around oerators to clarify grouping.


How "printf" works?

Its first argument is a string of characters to be printed, with each % indicating where one of the other(second, third, ...) arguments is to be substituted, and in what form it is to be printed. For instance, %d specifies an integer argument. By the way, "printf" is not a part of the C language; there is no input or output defined in C itself.

Among others, in printf, %% for itself

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末疲酌,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子哈误,更是在濱河造成了極大的恐慌慰丛,老刑警劉巖览妖,帶你破解...
    沈念sama閱讀 211,290評(píng)論 6 491
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異挥下,居然都是意外死亡揍魂,警方通過查閱死者的電腦和手機(jī)桨醋,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,107評(píng)論 2 385
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)现斋,“玉大人喜最,你說(shuō)我怎么就攤上這事∽#” “怎么了瞬内?”我有些...
    開封第一講書人閱讀 156,872評(píng)論 0 347
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)限书。 經(jīng)常有香客問我虫蝶,道長(zhǎng),這世上最難降的妖魔是什么蔗包? 我笑而不...
    開封第一講書人閱讀 56,415評(píng)論 1 283
  • 正文 為了忘掉前任秉扑,我火速辦了婚禮,結(jié)果婚禮上调限,老公的妹妹穿的比我還像新娘舟陆。我一直安慰自己,他們只是感情好耻矮,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,453評(píng)論 6 385
  • 文/花漫 我一把揭開白布秦躯。 她就那樣靜靜地躺著,像睡著了一般裆装。 火紅的嫁衣襯著肌膚如雪踱承。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,784評(píng)論 1 290
  • 那天哨免,我揣著相機(jī)與錄音茎活,去河邊找鬼。 笑死琢唾,一個(gè)胖子當(dāng)著我的面吹牛载荔,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播采桃,決...
    沈念sama閱讀 38,927評(píng)論 3 406
  • 文/蒼蘭香墨 我猛地睜開眼懒熙,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了普办?” 一聲冷哼從身側(cè)響起工扎,我...
    開封第一講書人閱讀 37,691評(píng)論 0 266
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎衔蹲,沒想到半個(gè)月后肢娘,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,137評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,472評(píng)論 2 326
  • 正文 我和宋清朗相戀三年蔬浙,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了猪落。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,622評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡畴博,死狀恐怖笨忌,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情俱病,我是刑警寧澤官疲,帶...
    沈念sama閱讀 34,289評(píng)論 4 329
  • 正文 年R本政府宣布,位于F島的核電站亮隙,受9級(jí)特大地震影響途凫,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜溢吻,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,887評(píng)論 3 312
  • 文/蒙蒙 一维费、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧促王,春花似錦犀盟、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,741評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至迅耘,卻和暖如春贱枣,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背颤专。 一陣腳步聲響...
    開封第一講書人閱讀 31,977評(píng)論 1 265
  • 我被黑心中介騙來(lái)泰國(guó)打工纽哥, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人栖秕。 一個(gè)月前我還...
    沈念sama閱讀 46,316評(píng)論 2 360
  • 正文 我出身青樓昵仅,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親累魔。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,490評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容