Created
January 7, 2017 19:42
-
-
Save lesovsky/56c44ee9707773d4d6e7e55a8f16efdf to your computer and use it in GitHub Desktop.
Using pointer to strings array.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* This example used in the following scenario: | |
| * 1. there are several sets of files. | |
| * 2. we need to choose specific set. | |
| * 3. handle files from this set in the loop. | |
| */ | |
| #include<stdio.h> | |
| int main() | |
| { | |
| int i; | |
| char *set_a[4] = { "C", "C++", "Java", "VBA" }; | |
| char *set_b[4] = { "Tea", "Cofee", "Water", "Oil" }; | |
| char *set_c[4] = { "Earth", "Venus", "Mercury", "Mars" }; | |
| char *(*ptr)[4]; // = &arr; | |
| /* here is the logic for choosing set */ | |
| ptr = &set_b; | |
| for(i = 0; i < 4; i++) | |
| printf("String %d : %s\n",i+1,(*ptr)[i]); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment