diff --git a/3_lesson/01_fun/.gitignore b/3_lesson/01_fun/.gitignore new file mode 100644 index 0000000..fab7372 --- /dev/null +++ b/3_lesson/01_fun/.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/3_lesson/01_fun/01_fun.pro b/3_lesson/01_fun/01_fun.pro new file mode 100644 index 0000000..fc18d89 --- /dev/null +++ b/3_lesson/01_fun/01_fun.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +CONFIG += console +CONFIG -= app_bundle +CONFIG -= qt + +SOURCES += main.c diff --git a/3_lesson/01_fun/main.c b/3_lesson/01_fun/main.c new file mode 100644 index 0000000..1a12753 --- /dev/null +++ b/3_lesson/01_fun/main.c @@ -0,0 +1,39 @@ +#include + +// 定义一个没有参数也没有返回值的函数 +void myfun1() +{ + printf("hello world\n"); + printf("nihao beijing\n"); + printf("welcome to 1000phone\n"); + + return; +} + +// 定义一个有参数的函数 +void myfun2(int a, int b) +{ + int sum; + sum = a + b; + + printf("%d + %d = %d\n", a, b, sum); +} + +// 定义一个有返回值的函数 +int myfun3(int a, int b) +{ + int sum; + sum = a + b; + + return sum; +} + +int main(int argc, char *argv[]) +{ + // 函数的调用 + // 函数在调用的时候如果没有参数,也必须加括号 + // 函数调用的时候不能加返回值类型 + myfun1(); + + return 0; +} diff --git a/课件/第3章_函数_笔记.pdf b/课件/第3章_函数_笔记.pdf new file mode 100644 index 0000000..3a3133e Binary files /dev/null and b/课件/第3章_函数_笔记.pdf differ