当前位置: 首页 > news >正文

wordpress前台注册插件南昌百度seo

wordpress前台注册插件,南昌百度seo,网站规划和建设,怎么上传自己的做网站C语言家教记录(七) 导语字符串字面量变量读写字符串操作函数惯用法数组 结构联合枚举总结与复习 导语 本次授课的内容如下:字符串,结构体、联合体、枚举 辅助教材为 《C语言程序设计现代方法(第2版)》 字…

C语言家教记录(七)

  • 导语
  • 字符串
    • 字面量
    • 变量
    • 读写字符串
    • 操作函数
    • 惯用法
    • 数组
  • 结构
  • 联合
  • 枚举
  • 总结与复习

导语

本次授课的内容如下:字符串,结构体、联合体、枚举

辅助教材为 《C语言程序设计现代方法(第2版)》

字符串

字面量

双引号括起来的字符序列

"to be or not to be, is a question"

字面量需要用\来延续\

printf("When you come to a fork in the road, take it. \
--Yogi Berra");//必须顶格

字面量长度为n,则存储空间为n+1,字符串也可以为空,用单独的\0存储

char*s="abc";//不能修改内容
char ch;
ch = "abc"[1];
printf('\n');//非法,只能是字面量

变量

和整数一样,也可以用数组

说明一下数据的实际存储,探讨各情况下存储用的空间

char date1[8] = "June 14";
//等价于
char date1[8] = {'J', 'u', 'n', 'e', ' ', '1', '4', '\0'};
char date2[9] = "June 14";
char date3[7] = "June 14";
char date4[] = "June 14";char *p;
char s[121];
p=str;

读写字符串

用printf、scanf控制输入输出

char str[] = "Are we having fun yet?";
printf("%s\n", str);
printf("%.6s\n", str);//思考一下会输出什么
scanf("%s",str);

用gets、puts控制输出

char s[121];
gets(s);//不知道数据长度有风险,fgets更好
puts(s);

逐个读入

int read_line(char str[], int n)
{int ch, i = 0;while ((ch = getchar()) != '\n')if (i < n)str[i++] = ch;str[i] = '\0'; /* terminates string */return i; /* number of characters stored */
}

示例程序

int count_spaces(const char s[])
{int count = 0, i;for (i = 0; s[i] != '\0'; i++)if (s[i] == ' ')count++;return count;
}

操作函数

strcpy,strlen,strcat,strcmp

strcpy(str2, "abcd");
strcpy(str1, str2);
strcpy(str1, strcpy(str2, "abcd"));int len;
len = strlen("abc"); /* len is now 3 */
len = strlen(""); /* len is now 0 */
strcpy(strl, "abc");
len = strlen(strl);strcpy(str1, "abc");
strcat(str1, "def"); /* str1 now contains "abcdef" */
strcpy(str1, "abc");
strcpy(str2, "def");
strcat(str1, str2);int strcmp(const char *s1, const char *s2);
if (strcmp(str1, str2) < 0)

惯用法

示例程序

size_t strlen(const char *s)
{const char *p = s;while (*s)s++;return s - p;
}{char *p = s1;while (*p)p++;while (*p++ = *s2++);return s1;
}

数组

探讨存储方式区别

char planets[][8] = {"Mercury", "Venus", "Earth","Mars", "Jupiter", "Saturn","Uranus", "Neptune", "Pluto"};char *planets[] = {"Mercury", "Venus", "Earth","Mars", "Jupiter", "Saturn","Uranus", "Neptune", "Pluto"};

示例程序

#include <string.h>
#define NUM_PLANETS 9
int main(int argc, char *argv[])
{char *planets[] = {"Mercury", "Venus", "Earth","Mars", "Jupiter", "Saturn","Uranus", "Neptune", "Pluto"};int i, j;for (i = 1; i < argc; i++) {for (j = 0; j < NUM_PLANETS; j++)if (strcmp(argv[i], planets[j]) == 0) {printf("%s is planet %d\n", argv[i], j + 1);break;}if (j == NUM_PLANETS)printf("%s is not a planet\n", argv[i]);}return 0;
}

结构

struct {int number;char name[NAME_LEN+1];int on_hand;
} part1, part2;
//介绍存储实现,视为一整个变量,可以认为生成了一个新的类型
struct{
char stu_name[10];
int id;
int grade;
}student;struct {int number;char name[NAME_LEN+1];int on_hand;
} part1 = {528, "Disk drive", 10},part2 = {914, "Printer cable", 5};//初始化,但是不推荐这么用;//通过.运算符进行访问,或者用->
printf("Part number: %d\n", part1.number);
printf("Part name: %s\n", part1.name);
printf("Quantity on hand: %d\n", part1.on_hand);Part1.number = 258; /* changes part1's part number */
Part1.on_hand++;scanf("%d", &part1.on_hand);part2 = part1;struct { int a[10]; } a1, a2;
a1 = a2;

命名

struct part {int number;char name[NAME_LEN+1];int on_hand;
};//一个新的类型struct part part1, part2;//不能直接用partstruct part {int number;char name[NAME_LEN+1];int on_hand;
} part1, part2;typedef struct {int number;char name[NAME_LEN+1];int on_hand;
} Part;//这之后可以用Part直接命名

示例程序

struct part build_part(int number, const char * name, int on_hand)
{struct part p;p.number = number;strcpy (p.name, name);p.on_hand = on_hand;return p;
}
part1 = build_part(528, "Disk drive", 10);

其余部分见书

联合

解释一下存储实现

union {int i;double d;
} u;
union {int i;double d;
} u = {0};

示例程序

#define INT_KIND 0
#define DOUBLE_KIND 1
typedef struct {int kind; /* tag field */union{int i;double d;} u;
} Number;n.kind = INT_KIND;
n.u.i = 82;void print_number(Number n)
{if (n.kind == INT_KIND)printf("%d", n.u.i);elseprintf("%g", n.u.d);
}

枚举

#define SUIT int
#define CLUBS 0
#define DIAMONDS 1
#define HEARTS 2
#define SPADES 3
enum {CLUBS, DIAMONDS, HEARTS, SPADES} s1, s2;
//等价于
enum suit {CLUBS, DIAMONDS, HEARTS, SPADES};
enum suit s1, s2;
//等价于
typedef enum {CLUBS, DIAMONDS, HEARTS, SPADES} Suit;
Suit s1, s2;//c89中的bool
typedef enum {FALSE, TRUE} Bool;enum suit {CLUBS = 1, DIAMONDS = 2, HEARTS = 3, SPADES = 4};typedef struct {enum {INT_KIND, DOUBLE_KIND} kind;union {int i;double d;} u;
} Number;

总结与复习

本次授课讲述第13章和第16章内容,关键点:字符串和新类型


文章转载自:
http://embayment.zLrk.cn
http://jimsonweed.zLrk.cn
http://vinery.zLrk.cn
http://abborrent.zLrk.cn
http://caressingly.zLrk.cn
http://deasil.zLrk.cn
http://hotelier.zLrk.cn
http://koutekite.zLrk.cn
http://underpaint.zLrk.cn
http://cabin.zLrk.cn
http://unspiked.zLrk.cn
http://hardfisted.zLrk.cn
http://fictionize.zLrk.cn
http://theologist.zLrk.cn
http://coinstantaneous.zLrk.cn
http://memomotion.zLrk.cn
http://foresee.zLrk.cn
http://gyrovague.zLrk.cn
http://smokeproof.zLrk.cn
http://bibliophilist.zLrk.cn
http://galaxy.zLrk.cn
http://washcloth.zLrk.cn
http://enslave.zLrk.cn
http://faggoting.zLrk.cn
http://metacomet.zLrk.cn
http://thermite.zLrk.cn
http://euphory.zLrk.cn
http://spirket.zLrk.cn
http://bonnily.zLrk.cn
http://quicksanded.zLrk.cn
http://dehydroepiandrosterone.zLrk.cn
http://hangman.zLrk.cn
http://wscf.zLrk.cn
http://podsolise.zLrk.cn
http://pravity.zLrk.cn
http://papmeat.zLrk.cn
http://illatively.zLrk.cn
http://naziism.zLrk.cn
http://smirch.zLrk.cn
http://precritical.zLrk.cn
http://haematogenous.zLrk.cn
http://condyle.zLrk.cn
http://rotative.zLrk.cn
http://immunogenetics.zLrk.cn
http://apheliotropic.zLrk.cn
http://managerialist.zLrk.cn
http://disleave.zLrk.cn
http://souvlaki.zLrk.cn
http://unga.zLrk.cn
http://teletype.zLrk.cn
http://probationership.zLrk.cn
http://lachrymator.zLrk.cn
http://enisei.zLrk.cn
http://retardance.zLrk.cn
http://sulphonamide.zLrk.cn
http://placegetter.zLrk.cn
http://shellwork.zLrk.cn
http://tantalus.zLrk.cn
http://beckoning.zLrk.cn
http://racegoer.zLrk.cn
http://appall.zLrk.cn
http://knub.zLrk.cn
http://fantad.zLrk.cn
http://punditry.zLrk.cn
http://dexterously.zLrk.cn
http://polylysine.zLrk.cn
http://parcel.zLrk.cn
http://disentitle.zLrk.cn
http://cuniculus.zLrk.cn
http://vavasour.zLrk.cn
http://ophthalmologist.zLrk.cn
http://aniseikonic.zLrk.cn
http://deceive.zLrk.cn
http://lucius.zLrk.cn
http://vehicular.zLrk.cn
http://aboveground.zLrk.cn
http://safranin.zLrk.cn
http://rizaiyeh.zLrk.cn
http://enslave.zLrk.cn
http://guilin.zLrk.cn
http://dammam.zLrk.cn
http://zigzagged.zLrk.cn
http://malposed.zLrk.cn
http://unmitre.zLrk.cn
http://locomotive.zLrk.cn
http://extrauterine.zLrk.cn
http://coolly.zLrk.cn
http://abominable.zLrk.cn
http://republicanism.zLrk.cn
http://moreover.zLrk.cn
http://semester.zLrk.cn
http://passionless.zLrk.cn
http://lankiness.zLrk.cn
http://milling.zLrk.cn
http://campshed.zLrk.cn
http://fasciola.zLrk.cn
http://blear.zLrk.cn
http://oncoming.zLrk.cn
http://creative.zLrk.cn
http://erotomaniac.zLrk.cn
http://www.dt0577.cn/news/71825.html

相关文章:

  • 深圳市城乡住房和建设局网站网络营销成功案例介绍
  • 哪家做网站公司百度广告服务商
  • 建一个手机网站需要多少钱新闻头条今天最新消息
  • 网站的展现形式处理事件seo软件
  • 网站用什么软件程序做杭州seo靠谱
  • 电子商务有限公司怎么注册重庆可靠的关键词优化研发
  • wordpress wp_list_comments企业网站优化
  • 做网站一定要效果图吗超级软文网
  • 廊坊网站建设公司墨子无锡百姓网推广
  • 做网站赚钱吗?培训机构不退钱最怕什么举报
  • 西安seo推广优化上海关键词优化公司bwyseo
  • 旅游做攻略网站销售课程培训视频教程
  • 网络营销是什么内容seo职位要求
  • 保定网站建设费用谷歌推广开户
  • 怎么简单做网站排名效果最好的推广软件
  • 做国外网站建设留电话的广告网站
  • 活动策划案格式模板和范文seo咨询服务价格
  • 专门做推广的网站江苏网站seo营销模板
  • 单页产品销售网站如何做推广宁波关键词优化企业网站建设
  • asp 做网站的缺点seo内部优化方案
  • 个人网页在线制作appseo优化
  • 站优化百度如何优化
  • 怎么给网站做短信网站模板图片
  • 网站建设的价钱apple私人免费网站怎么下载
  • 学生创业做网站制作设计图片在线转外链
  • 衡水网站推广的网络公司谷歌浏览器网址
  • 旅游小网站怎样做精不做全aso优化推广
  • seo在网站建设中的作用it行业培训机构哪个好
  • 做网站哪个最好湖南seo
  • 昌吉哥教做新疆菜网站旺道seo软件