diff --git a/2_lesson/04_quote/main.c b/2_lesson/04_quote/main.c index 3b6be86..b65175c 100644 --- a/2_lesson/04_quote/main.c +++ b/2_lesson/04_quote/main.c @@ -11,7 +11,7 @@ int main(int argc, char *argv[]) int i; for(i = 0; i< sizeof(a) / sizeof(int);i++) { - printf("a[%d] = %d\n",i,a[i]); + printf("a[%d] = %d\n",i,a[i]); } printf("************************\n"); diff --git a/2_lesson/05_array_char/.gitignore b/2_lesson/05_array_char/.gitignore new file mode 100644 index 0000000..fab7372 --- /dev/null +++ b/2_lesson/05_array_char/.gitignore @@ -0,0 +1,73 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/2_lesson/05_array_char/05_array_char.pro b/2_lesson/05_array_char/05_array_char.pro new file mode 100644 index 0000000..fc18d89 --- /dev/null +++ b/2_lesson/05_array_char/05_array_char.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +CONFIG += console +CONFIG -= app_bundle +CONFIG -= qt + +SOURCES += main.c diff --git a/2_lesson/05_array_char/main.c b/2_lesson/05_array_char/main.c new file mode 100644 index 0000000..e03fd66 --- /dev/null +++ b/2_lesson/05_array_char/main.c @@ -0,0 +1,15 @@ +#include + +int main(int argc, char *argv[]) +{ + // 定义一个字符数组,通过scanf函数输入字符串并输出结果 + // 通过赋值""这样的方式可以清除字符数组中的垃圾字符,让每一个元素都是\0 + char ch[32] = ""; + + // 数组名就是当前数组的首地址,所以scanf的第二个参数直接传数组名即可 + scanf("%s", ch); + + printf("ch = %s\n", ch); + + return 0; +}