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燈, 水草

請輸入看板名稱,例如:e-shopping站內搜尋

TOP