- Windows平台:Dev-c++, Visual studio 2017 community
- Linux 平台: gcc
使用Linux 平台C程式開發:
1.編輯程式: gedit myc_1_1.c
2.編譯: gcc myc_1_1.c -o myc_1_1
3.執行:./myc_1_1
windows 10截圖: alt+fn+ prt scr
/* myc_1_1, 我的第一個C程式碼 */
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
printf("Hello 偉大的恩師!\n"); /* 印出Hello 偉大的恩師! 字串 */
printf("Hello Taiwan!\n"); /* 印出Hello Taiwan! 字串 */
system("pause");
return ;
printf("Hello World!\n");
}
Question 1:#include <stdio.h>
include 是何意義??
stdio有何用途?
std英文全名為何?
i是何意義??o是何意義??
h = header =標頭檔有何用途?
https://zh.wikipedia.org/wiki/Stdio.h
Question 2:#include <stdlib.h>
stdlib有何用途?
std英文全名為何?
lib是何意義??
https://zh.wikipedia.org/wiki/Stdlib.h
Question 3: system("pause");
stdlib有何用途?
std英文全名為何?
lib是何意義??
https://zh.wikipedia.org/wiki/Stdlib.h
/* myc_1_1, 我的第一個C程式碼 */
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
printf("Hello 偉大的恩師!\n"); /* 印出Hello 偉大的恩師! 字串 */
printf("Hello Taiwan!\n"); /* 印出Hello Taiwan! 字串 */
// system("pause");
return ;
printf("Hello World!\n");
}
#include <stdio.h>
#include <stdlib.h>
printme()
{
printf("Hello 偉大的恩師!\n"); /* 印出Hello 偉大的恩師! 字串 */
printf("Hello Taiwan!\n") ; /* 印出Hello Taiwan! 字串 */
}
printtree()
{
printf(" \n");
printf(" \n");
printf(" * \n");
printf(" *** \n");
printf(" ***** \n");
printf(" ******* \n");
}
int main(void)
{
printf("我是史上最霹靂無敵的XXXX!\n");
printme();
printtree();
// system("pause");
return ;
printf("Hello World!\n");
}
error: ‘rreturn’ undeclared (first use in this function)
rreturn ;
^~~~~~~
myc_1_1.c:9:4: note: each undeclared identifier is reported only once for each function it appears in
warning: ‘return’ with no value, in function returning non-void
return ;
^~~~~~
myc_1_1.c:3:5: note: declared here
int main(void)
root@kali:~# gcc myc_1_1.c -o myc_1_1.exe
myc_1_1.c: In function ‘main’:
myc_1_1.c:9:4: warning: ‘return’ with no value, in function returning non-void
return ;
^~~~~~
myc_1_1.c:3:5: note: declared here
int main(void)
^~~~
root@kali:~# ls
Desktop Downloads myc_1_1.c Pictures Templates
Documents Music myc_1_1.exe Public Videos
root@kali:~# ./myc_1_1.exe
Hello 偉大的恩師!
Hello Taiwan!
root@kali:~# file myc_1_1.exe
myc_1_1.exe: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=649cc14a0f4144ffceaef39b1503230410fc9e24, not stripped
root@kali:~# strings myc_1_1.exe
/lib64/ld-linux-x86-64.so.2
libc.so.6
puts
__cxa_finalize
__libc_start_main
GLIBC_2.2.5
_ITM_deregisterTMCloneTable
__gmon_start__
_ITM_registerTMCloneTable
AWAVA
AUATL
[]A\A]A^A_
Hello
Hello Taiwan!
;*3$"
GCC: (Debian 7.2.0-18) 7.2.0
crtstuff.c
deregister_tm_clones
__do_global_dtors_aux
completed.7045
__do_global_dtors_aux_fini_array_entry
frame_dummy
__frame_dummy_init_array_entry
myc_1_1.c
__FRAME_END__
__init_array_end
_DYNAMIC
................有很多