diff --git a/.DS_Store b/.DS_Store
deleted file mode 100644
index fbdcdde3..00000000
Binary files a/.DS_Store and /dev/null differ
diff --git a/.gitignore b/.gitignore
index cebc5365..13b933b0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,13 @@
.gradle
-.idea
.settings
out
+cmake-build-debug
+.idea/
+lib_android/
+lib_flutter/
+lib_ios/
+lib_web/
+.idea/
+.settings/
+.DS_Store
+android/XPlay/app/.cxx/
\ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..58fdd470
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,6 @@
+[submodule "repo"]
+ path = repo
+ url = git@github.com:AdrianAndroid/repo.git
+[submodule "AndroidProject"]
+ path = AndroidProject
+ url = git@github.com:AdrianAndroid/AndroidProject.git
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 3b411700..00000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 2c1b7df1..00000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
deleted file mode 100644
index 797acea5..00000000
--- a/.idea/runConfigurations.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1ddf..00000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.project b/.project
deleted file mode 100644
index e5c087e3..00000000
--- a/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- AndroidHelper
- Project AndroidHelper created by Buildship.
-
-
-
-
- org.eclipse.buildship.core.gradleprojectbuilder
-
-
-
-
-
- org.eclipse.buildship.core.gradleprojectnature
-
-
-
- 1605245270438
-
- 30
-
- org.eclipse.core.resources.regexFilterMatcher
- node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
-
-
-
-
diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs
deleted file mode 100644
index 98515123..00000000
--- a/.settings/org.eclipse.buildship.core.prefs
+++ /dev/null
@@ -1,13 +0,0 @@
-arguments=
-auto.sync=false
-build.scans.enabled=false
-connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
-connection.project.dir=
-eclipse.preferences.version=1
-gradle.user.home=
-java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
-jvm.arguments=
-offline.mode=false
-override.workspace.settings=true
-show.console.view=true
-show.executions.view=true
diff --git a/AndroidHelper.iml b/AndroidHelper.iml
deleted file mode 100644
index dc1801d8..00000000
--- a/AndroidHelper.iml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/AndroidProject b/AndroidProject
new file mode 160000
index 00000000..29997cc2
--- /dev/null
+++ b/AndroidProject
@@ -0,0 +1 @@
+Subproject commit 29997cc2da6aedf247dc9b69858073185d3f7d9f
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..ac4d818e
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+# AndroidHelper
+AndroidHelper
diff --git a/build.gradle b/build.gradle
deleted file mode 100644
index 879358c5..00000000
--- a/build.gradle
+++ /dev/null
@@ -1,93 +0,0 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-//apply from: "config.gradle"
-buildscript {
- //ext.kotlin_version = "1.3.72"
- ext {
- minSdkVersion = 14
- targetSdkVersion = 29
- compileSdkVersion = 29
-
- androidGradlePluginVersion = "3.5.2"
- androidMavenGradlePluginVersion = "1.5"
- androidxAnnotationVersion = "1.1.0"
- androidxAppCompatVersion = "1.1.0"
- androidxCoreVersion = "1.1.0"
- androidxPreferenceVersion = "1.1.0"
- androidxRecyclerViewVersion = "1.1.0"
- androidxEspressoVersion = "3.2.0"
- androidxTestExtVersion = "1.1.1"
- androidxTestVersion = "1.2.0"
- junitVersion = "4.12"
- gradleBintrayPluginVersion = "1.6"
- kotlinVersion = "1.3.61"
- materialVersion = "1.0.0"
- }
-
- ext.kotlin_version = '1.5.0'//'1.3.72'
- ext.arouter_register_version = '1.0.2'
-
- repositories {
-// maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
- //maven { url uri("../repo") } // 配置maven仓库地址
- println("+++++++++++++++")
- println("/Users/flannery/Desktop/AndroidHelper/build.gradle")
- println("${rootProject.getRootDir().absolutePath}/repo")
- println("+++++++++++++++")
- maven { url uri("${rootProject.getRootDir().absolutePath}/repo") } // 配置maven仓库地址
- google()
- jcenter()
-// maven { url 'http://repo.duowan.com:8181/nexus/content/groups/public' }
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:4.2.1'//3.6.2
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
-
- classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.8'
-
- classpath 'me.ele:lancet-plugin:1.0.4'
- //classpath 'com.imooc.router:router-gradle-plugin:1.0.0'
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
- }
-}
-
-allprojects {
- repositories {
- //maven { url uri("../repo") } // 配置maven仓库地址
- // implementation 'com.flannery.utils:utils:1.0.0@aar'
- //maven { url uri("/Users/flannery/Desktop/AndroidHelper/repo") }
- maven { url uri("${rootProject.getRootDir().absolutePath}/repo") } // 配置maven仓库地址
- google()
- jcenter()
-// maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
-// maven { url 'https://dl.bintray.com/umsdk/release' }
-// maven {url 'http://maven.aliyun.com/nexus/content/repositories/releases/'}
-// maven { url 'http://repo.duowan.com:8181/nexus/content/groups/public' }
- }
-}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
-
-project.ext {
- compileSdkVersion = 28
- retrofitVersion = "2.4.0"
- gsonVersion = "2.8.2"
- cookieVersion = "v1.0.1"
-
- compileSdkVersion = 29
- minSdkVersion = 14
- targetSdkVersion = compileSdkVersion
-
- appCompatVersion = "1.2.0-rc01"
-
-
-}
-
-
-
-println("[life-cycle] 我是根目录的build.gradle")
-
-
-
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 62d4c053..00000000
Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 622ab64a..00000000
--- a/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
deleted file mode 100755
index fbd7c515..00000000
--- a/gradlew
+++ /dev/null
@@ -1,185 +0,0 @@
-#!/usr/bin/env sh
-
-#
-# Copyright 2015 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin or MSYS, switch paths to Windows format before running java
-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=`expr $i + 1`
- done
- case $i in
- 0) set -- ;;
- 1) set -- "$args0" ;;
- 2) set -- "$args0" "$args1" ;;
- 3) set -- "$args0" "$args1" "$args2" ;;
- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=`save "$@"`
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
deleted file mode 100644
index 5093609d..00000000
--- a/gradlew.bat
+++ /dev/null
@@ -1,104 +0,0 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/local.properties b/local.properties
deleted file mode 100644
index c6e50c36..00000000
--- a/local.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-## This file must *NOT* be checked into Version Control Systems,
-# as it contains information specific to your local configuration.
-#
-# Location of the SDK. This is only used by Gradle.
-# For customization when using a Version Control System, please read the
-# header note.
-#Sat Aug 14 23:22:38 CST 2021
-sdk.dir=/Users/flannery/Library/Android/sdk
diff --git a/repo b/repo
new file mode 160000
index 00000000..92c6c558
--- /dev/null
+++ b/repo
@@ -0,0 +1 @@
+Subproject commit 92c6c558cbdd688d9e2ec1e13d2167b4a560e5ac
diff --git a/settings.gradle b/settings.gradle
deleted file mode 100644
index dc459d66..00000000
--- a/settings.gradle
+++ /dev/null
@@ -1,2 +0,0 @@
-include ':leetcode'
-rootProject.name = "AndroidHelper"
\ No newline at end of file
diff --git a/src/leetcode/FirstIntelljClass.java b/src/leetcode/FirstIntelljClass.java
deleted file mode 100644
index 54d36450..00000000
--- a/src/leetcode/FirstIntelljClass.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package leetcode;
-
-public class FirstIntelljClass {
-
- public static void main(String[] args) {
- System.out.println("Hello world!");
- }
-
-}
diff --git "a/\346\226\207\347\253\240/\344\272\224\343\200\201\347\250\213\345\272\217\344\270\255\346\256\265\347\232\204\344\275\277\347\224\250.md" "b/\346\226\207\347\253\240/\344\272\224\343\200\201\347\250\213\345\272\217\344\270\255\346\256\265\347\232\204\344\275\277\347\224\250.md"
new file mode 100644
index 00000000..24ec0e75
--- /dev/null
+++ "b/\346\226\207\347\253\240/\344\272\224\343\200\201\347\250\213\345\272\217\344\270\255\346\256\265\347\232\204\344\275\277\347\224\250.md"
@@ -0,0 +1,72 @@
+五、程序中段的使用
+C语言中的全局区(静态区),实际上对应着下述几个段:
+只读数据段:RO Data
+读写数据段:RW Data
+未初始化数据段:BSS Data
+一般来说,直接定义的全局变量在未初始化数据区,如果该变量有初始化则是在已初始化数据区(RW Data),加上const修饰符将放置在只读区域(RO Data).
+例如:
+const char ro[ ]=”this is a readonlydata”; //只读数据段,不能改变ro数组中的内容,ro存放在只读数据段。
+char rw1[ ]=”this is global readwrite data”; //已初始化读写数据段,可以改变数组rw1中的内容。应为数值/是赋值不是把”this is global readwrite data” 地址给了rw1,不能改变char rw1[ ]=”this is global readwrite data”; //已初始化读写数据段,可以改变数组rw1中的内容。应为数值/是赋值不是把”this is global readwrite data” 地址给了rw1,不能改变”this is global readwrite data”的数值。因为起是文字常量放在只读数据段中
+
+char bss_1[100];//未初始化数据段
+
+const char *ptrconst = “constant data”; //”constant data”放在只读数据段,不能改变ptrconst中的值,因为其是地址赋值。ptrconst指向存放“constant data”的地址,其为只读数据段。但可以改变ptrconst地址的数值,因其存放在读写数据段中。
+
+实例讲解:
+int main()
+{
+ short b;//b放置在栈上,占用2个字节
+ char a[100];//需要在栈上开辟100个字节,a的值是其首地址
+ char s[]=”abcde”;
+ //s在栈上,占用4个字节,“abcde”本身放置在只读数据存储区,占6字节。s是一个地址
+ //常量,不能改变其地址数值,即s++是错误的。
+ char *p1;//p1在栈上,占用4个字节
+ char *p2 ="123456";//"123456"放置在只读数据存储区,占7个字节。p2在栈上,p2指向的内容不能更
+ //改,但是p2的地址值可以改变,即p2++是对的。
+ static char bss_2[100]; //局部未初始化数据段
+ static int c=0 ; //局部(静态)初始化区
+ p1 = (char *)malloc(10*sizeof(char)); //分配的内存区域在堆区
+ strcpy(p1,”xxx”); //”xxx”放置在只读数据存储区,占5个字节
+ free(p1); //使用free释放p1所指向的内存
+ return 0;
+}
+
+说明:
+1、只读数据段需要包括程序中定义的const型的数据(如:const char ro[]),还包括程序中需要使用的数据如“123456”。对于const char ro[]和const char * ptrconst的定义,它们指向的内存都位于只读数据据区,其指向的内容都不允许修改。区别在于前者不允许在程序中修改ro的值,后者允许在程序中修改ptrconst本身的值。对于后者,改写成以下的形式,将不允许在程序中修改ptrconst本身的值:
+const char * const ptrconst = “const data”;
+
+2、读写数据段包含了已经初始化的全局变量static char rw1[]以及局部静态变量static char rw2[]。rw1和rw2的差别在于编译时,是在函数内部使用的还是可以在整个文件中使用。对于前者,static修饰在于控制程序的其他文件时候可以访问rw1变量,如果有static修饰,将不能在其他的C语言源文件中使用rw1,这种影响针对编译-连接的特性,但无论有static,变量rw1都将被放置在读写数据段。对于后者rw2,它是局部的静态变量,放置在读写数据区;如果不使用static修饰,其意义将完全改变,它将会是开辟在栈空间局部变量,而不是静态变量。
+
+3、未初始化数据段,事例1中的bss_1[100]和 bss_2[200]在程序中代表未初始化的数据段。其区别在于前者是全局的变量,在所有文件中都可以使用;后者是局部的变量,只在函数内部使用。未初始化数据段不设置后面的初始化数值,因此必须使用数值指定区域的大小,编译器将根据大小设置BBS中需要增加的长度。
+
+4、栈空间包括函数中内部使用的变量如short b和char a[100],以及char *p1中p1这个变量的值。
+ 1)变量p1指向的内存建立在堆空间上,堆空间只能在程序内部使用,但是堆空间(例如p1指向的内存)可以作为返回值传递给其他函数处理。
+ 2)栈空间主要用于以下3类数据的存储:
+ a、函数内部的动态变量
+ b、函数的参数
+ c、函数的返回值
+ 3)栈空间主要的用处是供函数内部的动态变量使用,变量的空间在函数开始之前开辟,在函数退出后由编译器自动回收。看一个例:
+ int main( )
+ {
+ char *p = "tiger";
+ p[1] = 'I';
+ p++;
+ printf("%sn",p);
+ }
+编译后提示:段错误
+
+分析:
+char *p = "tiger";系统在栈上开辟了4个字节存储p的数值。"tiger"在只读存储区中存储,因此"tiger"的内容不能改变,*p="tiger",表示地址赋值,因此,p指向了只读存储区,因此改变p指向的内容会引起段错误。但是因为p是存放在栈上,因此p的数值是可以改变的,因此p++是正确的。
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git "a/\346\226\207\347\253\240/\345\205\255\343\200\201const\347\232\204\344\275\277\347\224\250.md" "b/\346\226\207\347\253\240/\345\205\255\343\200\201const\347\232\204\344\275\277\347\224\250.md"
new file mode 100644
index 00000000..a576e90a
--- /dev/null
+++ "b/\346\226\207\347\253\240/\345\205\255\343\200\201const\347\232\204\344\275\277\347\224\250.md"
@@ -0,0 +1,45 @@
+1、前言:
+const是一个C语言的关键字,它限定一个变量不允许被改变。使用const在一定程序上可以提高程序的健壮性,另外,在观看别人代码的时候,清晰理解const所起的作用,对理解别人的程序有所帮助。
+2、const变量和常量
+ 1)const修饰的变量,其值存放在只读数据段中,其值不能被改变。称为只读变量。其形式为 const int a=5;此处可以用a代替5
+ 2)常量:其也存在只读数据段中,其数值也不能被改变。其形式为"abc" ,5
+3、const 变量和const限定的内容,先看一个事例:
+ typedef char* pStr;
+ int main( )
+ {
+ char string[6] = “tiger”;
+ const char *p1 = string;
+ const pStr p2 = string;
+ p1++;
+ p2++;
+ printf(“p1=%snp2=%sn”,p1,p2);
+ }
+ 程序经过编译后,提示错误为
+ error:increment of read-only variable ‘p2’
+
+ 1)const 使用的基本形式为:const char m;
+ //限定m 不可变
+ 2)替换1式中的m,const char *pm;
+ //限定*pm不可变,当然pm是可变的,因此p1++是对的
+ 3)替换1式中的char,const newType m;
+ //限定m不可变,问题中的pStr是一种新类型,因此问题中p2不可变,p2++是错误的。
+4、const 和指针
+
+类型声明中const用来修饰一个常量,有如下两种写法:
+
+1)const在前面
+ const int nValue;//nValue是const
+ const char *pContent;//*pContent是const,pConst可变
+ const (char *)pContent;//pContent是const,*pContent可变
+ char *const pContent;//pContent是const,*pContent可变
+ const char * const pContent;//pContent和*pContent都是const
+2)const 在后面与上面的声明对等
+ int const nValue;// nValue是const
+ char const *pContent;//*pContent是const, pContent可变
+ (char *) constpContent;//pContent是const, *pContent可变
+ char* const pContent;// pContent是const, *pContent可变
+ char const* const pContent;//pContent和*pContent都是const
+
+说明:const和指针一起使用是C语言中一个很常见的困惑之处,下面是两天规则:
+ 1)沿着*号划一条线,如果const位于*的左侧,则const就是用来修饰指针所指向的变量,即指针指向为常量;如果const位于*的右侧,const就是修饰指针本身,即指针本身是常量。你可以根据这个规则来看上面声明的实际意义,相信定会一目了然。
+ 2)对于const (char *) ; 因为char *是一个整体,相当于一个类型(如char),因此,这是限定指针是const。
\ No newline at end of file