php fputs函数用法,c,_fputs函数无法写东西进文件?,c - phpStudy

fputs函数无法写东西进文件?

出错内容请看代码中的汉字注释。

#include "precompile.h"

Status macro_collect(const char *sourcefile,

struct macro_argument **macro_argument_head,

struct macro_no_argument **macro_no_argument_head)

{

int flag1 = 1;

int flag2 = 1;

FILE *fpa;

FILE *fpb;

char curLine[MAX_LINE];

ma *malhead; /* ma --> struct macro_argument */

ma *maltail;

mna *mnalhead;/* mna -->struct macro_no_argument */

mna *mnaltail;

malhead = (ma *)malloc(sizeof(ma));

maltail = malhead;

mnalhead = (mna *)malloc(sizeof(mna));

mnaltail = mnalhead;

if (NULL == (fpa=fopen(sourcefile, "r")) ||

NULL == (fpb=fopen("temp2.c", "w")))

{

printf("Cannot open the file!\n");

return ERROR;

}

while (TRUE)

{

if (feof(fpa))

{

break; // end of file

}

if (NULL == fgets(curLine, MAX_LINE-1, fpa))

{

printf("fgets error!\n");

return ERROR;

}

delete_blank(curLine);

if (1 == flag1)

{

flag1 = 0;

maltail->next = (ma *)malloc(sizeof(ma));

maltail = maltail->next;

}

if (1 == flag2)

{

flag2 = 0;

mnaltail->next = (mna *)malloc(sizeof(mna));

mnaltail = mnaltail->next;

}

/*

* If macro_collect_line() return SUCCESS, which means the current * line's macro information has been collected successfully, then * continue to check the next line.

* Else return UNSUCCESS, which means the current line has no macro, * then copy the current line to the "temp2.c" directly and continue * to check the next line. */

if (UNSUCCESS == macro_collect_line(curLine, &maltail, &mnaltail,

&flag1, &flag2))

{

printf("%s\n",curLine);/* 此处字符串curLine可以正常输出内容,但是接下来的fputs函数却没有向文件temp2.c中写入该字符串。*/

if (EOF == fputs(curLine, fpb))

{

printf("Write file error!\n");

return ERROR;

}

}

}

fclose(fpa);

fclose(fpb);

(*macro_argument_head) = malhead->next;

(*macro_no_argument_head) = mnalhead->next;

return OK;

}

相关阅读:

boss让我实现下图的这个功能,能实现添加元素,修改以及删除,我感觉无法下手

coordinatorLayout嵌套recyclerview

使用jquerymobile,如果一个big.html有3个并列的page(A page,B page,C page)

有没有用markdown做成的页面链接

国外地图标记(非洲)

sass 能否内联导入 css?

请教一个prototype的类型问题。tostring()检测

git如何合并两个远端分支?

有人用过Howler.js这个插件吗?遇到ios兼容性问题了,求解答

js中继承之后,子构造器new出来的对象的constructor为什么是父构造器?

前端写JS时候如何实现类似Xcode中playgourd的热替换的功能?

mint-ui vue2.0 调试发现body有个8px的外边距 是什么鬼?官方默认没清么?

在windows上使用nginx拦截node静态资源请求后,怎样从请求中看出来啊?

无限极分类导入问题

select2 如何禁止用户写入tags?

用js如何修改浏览器默认的下载框

css3中的translateZ能够改变元素的层叠顺序吗?

vue做的项目IE下显示空白 调试报错 求解

iOS如何判断竖排方向锁定

Atom beautify 格式化PHP无效果.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值