开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
Xcode: C
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
问题(Question):
两个文件档内容合并再输出到萤幕上
喂入的资料(Input):
两个文件档
try: abcde
try1: fghij
预期的正确结果(Expected Output):
abcdefghij
错误结果(Wrong Output):
只显示e
程式码(Code):(请善用置底文网页, 记得排版)
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fptr, *fptr1;
char str[ 7] ;
fptr1 = fopen("/Users/huyentung/Desktop/test/test1/test1/try1.txt", "r+");
if ((fptr = fopen("/Users/huyentung/Desktop/test/test1/test1/try.txt", "r"))
== NULL)
puts("unable to open");
else
while (fgets(str, 7, fptr) != NULL)
{
fputs(str, fptr1);
}
fclose(fptr1);
fclose(fptr);
if ((fptr1= fopen("/Users/huyentung/Desktop/test/test1/test1/try1.txt",
"r")) == NULL)
puts("unable to open");
else
while (fgets(str, 7, fptr1) != NULL)
printf("%s\n", str);
fclose(fptr1);
return 0;
}
补充说明(Supplement):
刚学C一个月,请鞭小力点QQ