C language print two-dimensional character array

Source: Internet
Author: User

C language is not often used, it is almost forgotten. Usually you have to use more skilled ah!

#include <stdio.h>void func1 (int m, char *str[]) {int i =0; printf ("%s\n", "int func1------"); for (; i<m; i++) {PR intf ("%s\n", Str[i]);}} void Func2 (int m, char **str) {int i =0; printf ("%s\n", "int func2------"), for (; i<m; i++) {printf ("%s\n", * (Str+i));} }void func3 (int m, char str[][8]) {int i =0; printf ("%s\n", "int func3------"), for (; i<m; i++) {printf ("%s\n", Str[i]) ;}} int main (int argc, char *args[]) {char *country1[] = {"China", "Russia", "America"}; func1 (3, Country1); Func2 (3, &amp ; Country1[0]); Char country2[][8] ={"China", "Russia", "America"}; func3 (3, Country2);}

Because the maximum value of each string needs to be passed in, FUNC3 has limitations and is not recommended. Func1 is the easiest to understand.

C language print two-dimensional character 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.