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

What are the types of arrays in C language?

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what are the types of arrays in c language". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. let's study and learn "what are the types of arrays in c language"?

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 your reading. the above is the content of "what are the types of arrays in c language". After the study of this article, I believe you have a deeper understanding of the types of arrays in c language. the specific use also needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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: 288

*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

Internet Technology

Wechat

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

12
Report