[問題] 堆疊的判斷
寫一程式讀檔
也就是上面那篇的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
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章