我正在使用Visual Studio 2013來嘗試和學習C語言。C - 找不到這個錯誤:「C2106:'=':左操作數必須是l值」
我使用的是著名K&R book後字面上複製和從書到Visual Studio 2013粘貼下面這段代碼,我得到了錯誤:
1錯誤C2106:「=」:左操作數必須是左值
2智能感知:表達式必須修改的左值
#include <stdio.h>
#define IN 1 /* inside a word */
#define OUT 0 /* outside a word */
/* count lines, words, and characters in input */
main()
{
int c, nl, nw, nc, state;
state = OUT;
nl = nw = nc = 0;
while ((c = getchar()) != EOF) {
++nc;
if (c == '\n')
++nl;
if (c == ' ' || c == '\n' || c = '\t')
state = OUT;
else if (state == OUT)
state = IN;
++nw;
}
printf("%d %d %d\n", nl, nw, nc);
}
似乎錯誤來源於聲明:
if (c == ' ' || c == '\n' || c = '\t')
但我真的無法弄清楚什麼是錯,沒有提到代碼是從書中直接的事實。
任何幫助將不勝感激!
謝謝!
也許你的剪貼板被打破 – 2015-01-31 21:13:58
:3。我想我需要休息一下。 – xashcorex 2015-01-31 21:18:35