[問題] 堆疊的判斷

看板C_and_CPP (C/C++)作者 (逆鱗)時間15年前 (2010/11/17 15:42), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
寫一程式讀檔 也就是上面那篇的get token() case '@': //if this is error strLexeme[tmpe++]=nextChar; nextChar = getc(fptr1); test = tmpe; while(1) { if(nextChar!=' ' && nextChar!= '\t' && nextChar!='\r' && nextChar!='\n' && ((nextChar >= 'a' && nextChar<= 'z') || (nextChar >= 'A' && nextChar<= 'Z'))){ strLexeme[tmpe++] = nextChar; }else{ break;} nextChar = getc(fptr1); } strLexeme[tmpe] = '\0'; if(test != tmpe ) { strcpy(strTType,"error"); }else break; 上述的程式碼是如果讀到@的話,就是error 例如@abc就是錯的 但問題來了,這種寫法只能在先讀到@後做判斷 如果讀的是ab@c的話 會被拆成ab是合法變數 @c是不合法變數 請問要怎麼改? -- 柏油八神嚐嚐我的╱ ̄ ̄ ╲ ◤ ◥ 幹你媽的!老子的 大洨薙吧! ○~ 「八瓦斯」比你那招 \ □︵□| 厲害千百倍! \ ▽◢ ~ ◥◣皿╱◆ ) ︿_ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.170.7.39

11/17 17:30, , 1F
再加個布林值看看
11/17 17:30, 1F
文章代碼(AID): #1CuuTOeH (C_and_CPP)
文章代碼(AID): #1CuuTOeH (C_and_CPP)