Programming 板


LINE

※ 引述《akdsy (我很想你)》之铭言: : ※ 引述《halajohn (Wei Hu)》之铭言: : : 不就是用 debug mode 然後 step by step 去看为什麽 output : : 不是你想要的吗? : 我当初也是想说要这样作, : 但是呢我给他设完break point之後,(我给他设在lex所产生的.c档里) : 他给我出现类似"中断点出现太多的讯息"......(我只设了两个= =") : 可能是有用到lex的语法,(lex在win32上操作) : 接下来按下确定之後, : 我还是给他继续侦错,(不过那些break point已经消失了) : 所以他跑进去main里的yylex()........这算是lex的预设,一定会进去 : main 里也只有那一行( yylex() )而已... : 侦错箭头就指向yylex()....然後就不动了, : 所以想请问没有前辈使用过lex所产生的.c的compiler完之後, : 再去对他侦错的? 之前那个错误已经用别的写法来去除了! 现在有另一个问题产生(有5~6 个error) 是关於档案的的读取(.txt)...有监於有版友希望我po出原始码...大概是这样... 以下是 ***.l档 %{ #include <stdio.h> #include <string.h> #include <malloc.h> #include <fstream.h> void read_file(char*name); %} %% 这里的lex应该是正确的,因为之前我已经测过了 %% main(int argc, char *argv[]) { read_file(argv[1]); //这是打算传入档案名称 yylex(); } void read_file(char*word) { printf("file name is %s\n",word); FILE *fp = fopen(word,"r"); //若从这里以下全部注解起来,结果将会是正确的 char ch ; if(fp==NULL){ printf("无法开启档案\n"); return 0; } else { printf("档案开启成功\n"); while((ch=fgetc(fp)) !=EOF ){ putchar(ch); } } yywrap() {} 以下是错误讯息: Compiling... lex.yy.c lex.yy.c(1603) : warning C4013: 'exit' undefined; assuming extern returning int test5.l(176) : error C2275: 'FILE' : illegal use of this type as an expression 这里我不知道为什麽会错 不是已经有include<stdio.h>吗? 我还多用了一个<fstream.h> 以下几乎都是因为读档产生错误..... c:\program files\microsoft visual studio\vc98\include\stdio.h(156) : see declaration of 'FILE' test5.l(176) : error C2065: 'fp' : undeclared identifier test5.l(178) : error C2143: syntax error : missing ';' before 'type' test5.l(180) : warning C4047: '==' : 'int ' differs in levels of indirection from 'void *' test5.l(183) : warning C4098: 'read_file' : 'void' function returning a value test5.l(189) : error C2065: 'ch' : undeclared identifier test5.l(189) : warning C4047: 'function' : 'struct _iobuf *' differs in levels of indirection from 'int ' test5.l(189) : warning C4024: 'fgetc' : different types for formal and actual parameter 1 test5.l(196) : error C2143: syntax error : missing ';' before '{' test5.l(197) : fatal error C1004: unexpected end of file found Error executing cl.exe. lex.yy.obj - 6 error(s), 5 warning(s) 感谢大家帮忙!! --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.116.117.151
1F:推 abcdefghi:vc96支援c99了吗 ? 没有的话,把FILE *fp 140.113.23.107 04/17 16:32
2F:→ abcdefghi:这一行宣告要拿到 printf() 的前面. 140.113.23.107 04/17 16:32
3F:→ abcdefghi:char ch; 这一行也要拿到前面. 140.113.23.107 04/17 16:34
4F:推 akdsy:喔喔!过了耶!!!!!感谢140.116.117.151 04/17 16:42







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Tech_Job站内搜寻

TOP