#include "stdafx.h" #include <stdio.h> #include <conio.h> #define eof -1; int main() { int c; printf("Make input>\n"); c = getchar(); while (c != eof) // 1>5.cpp(12): error C2143: синтаксическая ошибка: отсутствие ")" перед ";" куда ")" воткнуть ее, она же там не нужна { putchar(c); c = getchar(); } getch(); }
- haskell.org/definition/haskell2010.pdf I have already reached the comment threshold. He will not take root, or practical techies will not take root, who knows ... But this discussion is no longer on the topic of error. - alexlz
3 answers
It is necessary to define the macro eof like this:
#define eof -1
Without; in the end
Better yet:
#define eof (-1)
In the answer @mikillskegg (well, imechko, you break your fingers) is given the correct option. You put eof
in the body macro ;
. You insert it into the resulting text. What happens, imagine. Yes, and in the 21st century, indulging in the definitions of constants for #define
is not the case. Use at least enum'ami.
- 2What does not like the name? Normal Old Norse nickname :) - skegg
- And if in essence, then define is very widely used to define constants. Enumerations are convenient for determining several constants at once, and for one why should you take a steam bath? Although, this is all a matter of taste. Most likely, the compiler will produce the same assembly code. - skegg
- What nicknames do not like, I already wrote - you can break your fingers. And here about
#define
are macro substitutions, and syntactic control goes already later. Their careless use leads, at best, to incomprehensible errors, such as this one, at worst - hard-to-find errors, which are not caught by syntactic control. They came from the very beginning, when the capabilities of computers / compilers were very modest, and it is better to leave them there. And for single constants there is a descriptorconst
- alexlz - Yes, but enumerations have one restriction: they allow to define only integer constants. Where floating commas, text constants, etc. are needed without macro substitutions you will not manage. Especially where simple constants can slow down the work. Errors? With generally requires great care. Why are there only buffer overflows or memory leaks! I here in the text glibc met a macro for ~ 500 lines of text. This, of course, is too much. But it works the same! All techniques are good in their place, all have their pros and cons, all must be used wisely. - skegg
- oneExcessive confidence in the compiler leads to even more difficult to catch errors. Excessive rigor of the language is insurance for rabbits that are not suitable for climbing, only interfering with cats (who can climb). Moral - in everything you need to know the measure and carefully study the materiel. - avp
while(c != eof) / 1>5
Probably, the whole condition should be cumulative brackets.
- First, 1> 5 is not a condition, but a compiler output. Secondly, it is more likely that the problem is in the eof itself. - gecube