首页IT科技the indispensable opposition课后答案(Pointers and Text Strings)

the indispensable opposition课后答案(Pointers and Text Strings)

时间2025-06-15 02:44:36分类IT科技浏览4156
导读:Pointers and Text Strings...

Pointers and Text Strings

Historically, text strings in C have been implemented as arrays of characters, with the last byte in the string being a zero, or the null character \0. Most C implementations come with a standard library of functions for manipulating strings. Many of the more commonly used functions expect the strings to be null terminated strings of characters. To use these functions requires the inclusion of the standard C header file "string.h".

A statically declared, initialized string would look similar to the following:

static const char *myFormat = "Total Amount Due: %d";

The variable myFormat can be viewed as an array of 21 characters. There is an implied null character (\0) tacked on to the end of the string after the d as the 21st item in the array. You can also initialize the individual characters of the array as follows:

static const char myFlower[] = { P, e, t, u, n, i, a, \0 };

An initialized array of strings would typically be done as follows:

static const char *myColors[] = { "Red", "Orange", "Yellow", "Green", "Blue", "Violet" };

The initilization of an especially long string can be split across lines of source code as follows.

static char *longString = "Hello. My name is Rudolph and I work as a reindeer " "around Christmas time up at the North Pole. My boss is a really swell guy." " He likes to give everybody gifts.";

The library functions that are used with strings are discussed in a later chapter.

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
如何复制收费的文章链接(文章的复制率自然就会降低,这是避免版权纠纷的前提条件,同时也是提高用户体验和排名的关键。因此,在写作伪原创文章的时候,一定要认真选择好题目,从题目中总结出文章的主旨,避免与其他同类型文章内容雷同,图片、段落等格式方面也要学会巧妙切换,避免过于雷同。) bios设置第一启动项为硬盘(如何设置BIOS开机启动项将开机第一启动项设置为U盘或光驱)