1 /* 2 * Copyright 2011, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include<stdio.h> 18 static void hello_function(const char *ptr){ 19 printf(ptr); 20 } 21 int my_add(int para_x, int para_y){ 22 return para_x + para_y; 23 } 24 int global_z_i; 25 double global_z_d; 26 int global_big_z_i[1000]; 27 double global_big_z_d[1000]; 28 static int global_static_z_i; 29 static double global_static_z_d; 30 static int global_static_big_z_i[1000]; 31 static double global_static_big_z_d[1000]; 32 int global_z_i_init = 1; 33 double global_z_d_init = 1.1; 34 /*extern int extern_z_i; */ 35 /*extern double extern_z_d;*/ 36 int main(){ 37 static int local_static_z_i; 38 static double local_static_z_d; 39 static int local_static_z_i_init = 2; 40 static double local_static_z_d_init = 2.2; 41 local_static_z_i = local_static_z_i_init; 42 local_static_z_d = local_static_z_d_init; 43 printf("%d %f\n", local_static_z_i, local_static_z_d); 44 printf("%d %f\n", local_static_z_i_init, local_static_z_d_init); 45 hello_function("Hello world!1\n"); 46 hello_function("Hello world!2\n"); 47 hello_function("Hello world!3\n"); 48 global_z_i = my_add(1,2); 49 global_z_d = 3.3; 50 printf("%d %f\n", global_z_i, global_z_d); 51 global_big_z_i[100] = 4; 52 global_big_z_d[100] = 4.4; 53 printf("%d %f\n", global_big_z_i[100], global_big_z_d[100]); 54 global_static_z_i = my_add(2,1); 55 global_static_z_d = 3.3; 56 printf("%d %f\n", global_static_z_i, global_static_z_d); 57 int local_z_i = global_static_z_i = global_z_i; 58 double local_z_d = global_static_z_d = global_z_d; 59 printf("%d %f\n", local_z_i, local_z_d); 60 global_static_big_z_i[500] = 5; 61 global_static_big_z_d[500] = 5.5; 62 printf("%d %f\n", global_static_big_z_i[500], global_static_big_z_d[500]); 63 global_z_i_init = 6; 64 global_z_d_init = 6.6; 65 printf("%d %f\n", global_z_i_init, global_z_d_init); 66 /*printf("%d %f\n", extern_z_i, extern_z_d);*/ 67 return 0; 68 } 69