Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

There are several types of arrays in c language

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces several types of arrays in c language, which can be used for reference. Interested friends can refer to them. I hope you will gain a lot after reading this article.

1. An one-dimensional array. The type before the array name when declared is the type of the array element.

Example: inta [4]; this indicates that the length of an integer array is 4, and each element is an integer array.

The assignment method for grouping is as follows:

Array type array name [length of custom array] array name [subscript] = value int array name [length of array] = {the first element of the array, the second element of the array,..., the nth element of the array}

We usually assign values to arrays through for loops.

Note: if an element in the array is not assigned, the default value is 0.

2, two-dimensional array, can be used as a kind of table, it has rows and columns.

Example: array type array name [length of one-dimensional array in array] [length of two-dimensional array in array]

Assignment of two-dimensional array:

Array type array name [length of one-dimensional array] [length of two-dimensional array]; array name [subscript of an element of an one-dimensional array] [subscript of an element of a two-dimensional array] = value

3. Character array, there is no concept of string in c language, only a single character, so a string is called a character array.

The definition of character array is as follows:

Char string name [string length] = "here is your string"

In addition, the string in c language should end with\ 0, otherwise the character array does not have an end.

Thank you for reading this article carefully. I hope the article "there are several types of arrays in c language" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report