C语言 记事本

Python026

C语言 记事本,第1张

程序本身没有问题。应是中文路径问题。

如果程序和数据在同一文件夹:

#include <stdio.h>

#include <stdlib.h>

int main () {

FILE *fpa, *fpb

if((fpa=fopen("a.txt","r")) == NULL){

printf("can not open file a.txt !\n")

exit(0)

}

if((fpb=fopen("b.txt","w")) == NULL){

printf("can not open file b.txt!\n")exit(0) }

while(!feof(fpa))

fputc(fgetc(fpa), fpb)

fclose(fpa)fclose(fpb)

return 0

}

开个命令窗,用 CD 命令 进当前文件夹。

用 CL asd2.c 编译程序(假定程序名是 asd2.c)

然后 打命令 asd2.exe

就行了。

记事本可以编辑C语言。下面,我们来看看如何利用记事本进行c语言编程吧。

记事本

新建一张记事本,修改名称为【hello world】,如下图所示

编写代码:

#include <stdio.h>

main() {

printf("hello worldn")

}

保存记事本

然后保存记事本,修改后缀名为【.c】,如下图所示:

就会变成C语言代码了,如下图所示: