A personal understanding of an int array and a char array

Source: Internet
Author: User

In a char array, either one-dimensional or two-dimensional, each piece of data is separated by the provided starting address into a string that is processed as the program executes. so the function of char[] is to provide only the corresponding starting address as a formal parameter.

Char[] instead of using the = sign for exchanging content with each other, use strcpy (A, A, a), where a is the starting address for "assigned" char[, and B is the starting address of the "value to assign" char[]. To modify one of these characters, you can use the = sign

In addition for example char* a= "ABCD" and char b[5]= "ABCD"; the difference is that B can arbitrarily modify a character in a character array, and a cannot be modified after initialization.

But a can change the address it points to, and B is an array named "Pointer constant" and cannot modify its point to address.

The two-dimensional int array int a[3][10], which is to be processed by entering one of the 3 one-dimensional arrays as formal parameters into the function. For example:

#include <stdio.h>
void and1 (int b[])
{
B[1] = b[1] + 1;
}
int main (void)
{
int a[3][2] = {1,2,3,4,5,6};
AND1 (a[2]);
printf ("%d", a[2][1]);
return 0;
}

The purpose of this program is to add a second element of the third array in the two-dimensional int array. Why do you write this, because the int array is a numeric value that is processed according to 4 bytes ,

Formal parameter b[] just want to provide a starting address for the one-dimensional array you want to work with.

A personal understanding of an int array and a char array

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.