Data Structures Using C

更新时间:2023-06-29 06:35:54 阅读: 评论:0

橄榄油能不能炒菜
Module 815
Data Structures Using C圆明园十二兽首
M. Campbell©  1993  Deakin University
小学方程Module 815Data Structures Using C
Aim
After working through this module you should be able to create and u
new and complex data types within C programs.
Learning objectives
After working through this module you should be able to:
1.Manipulate character strings in C programs.
2.Declare and manipulate single and multi-dimensional arrays of the C
data types.
3.Create, manipulate and manage C pointers to data elements.
4.Create and manage complex data types in C.
5.U unions to define alternate data ts for u in C programs.
6.Allocate memory to variables dynamically.
7.Manipulate characters and bits.
Content
Strings.
Arrays.
阖家幸福的意思是什么
Pointers.
Data definitions – Structures.
Data definitions – Unions.
红曲米的食用方法
Dynamic allocation of data
Character and bit manipulation
Learning Strategy
Read the printed module and the assigned readings and complete the
exercis as requested.
Asssment
Completion of exercis and the CML test at the end of the module.
Page 813-1
Module 815Data Structures Using C References & resources
The C Programming Language. 2nd. edition
Brian W. Kernighan and Dennis M. Ritchie
Prentice-Hall, 1988
Turbo C/C++ Manuals.
Turbo C/C++ MS DOS compiler.
Page 813-2
Module 815Data Structures Using C
Objective 1After working through this module you should be able to manipulate character strings in C programs
凝视作文
Strings
A string is a group of characters, usually letters of the alphabet. In
order to format your printout in such a way that it looks nice, has
meaningful titles and names, and is aesthetically pleasing to you and the
people using the output of your program, you need the ability to output
text data. We have ud strings extensively already, without actually
defining them. A complete definition of a string is ‘a quence of char
type data terminated by a NULL character,’.
When C is going to u a string of data in some way, either to compare
it with another, output it, copy it to another string, or whatever, the
functions are t up to do what they are called to do until a NULL
character (which is usually a character with a zero ASCII code number)
is detected. You should also recall (from Module 813: Fundamental
Programming Structures in C) that the char type is really a special form无法定位
of integer – one that stores the ASCII code numbers which reprent
characters and symbols.
An array (as we shall discover shortly) is a ries of homogeneous
pieces of data that are all identical in type. The data type can be quite
complex as we will e when we get to the ction of this module
discussing structures. A string is simply a special ca of an array, an
array of char type data. The best way to e the principles is by u of
an example [CHRSTRG.C].
#include "stdio.h"
void main( )
{
char name[5];/* define a string of characters*/ name[0] = 'D';
name[1] = 'a';
name[2] = 'v';
name[3] = 'e';
name[4] = 0;/* Null character - end of text*/
printf("The name is %s\n",name);
printf("One letter is %c\n",name[2]);
printf("Part of the name is %s\n",&name[1]);
}
The data declaration for the string appears on line 4. We have ud this
declaration in previous examples but have not indicated its meaning.
The data declaration defines a string called name which has, at most, 5
characters in it. Not only does it define the length of the string, but it
also states, through implication, that the characters of the string will be
numbered from 0 to 4. In the C language, all subscripts start at 0 and
increa by 1 each step up to the maximum which in this ca is 4. We
have therefore named 5 char type variables: name[0], name[1],
爱因斯坦的名言Page 813-3

本文发布于:2023-06-29 06:35:54,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1064538.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:炒菜   圆明园   方程   凝视   无法
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图