Bill said:
On Feb 12, 9:48 am, Chris Dollin <
[email protected]> wrote:
me@here> make
foo.c:1: conio.h: No such file or directory
foo.c:4: process.h: No such file or directory
foo.c:39: unterminated comment
me@here> indent foo.c
indent: foo.c:49: Warning:Unterminated string constant
indent: foo.c:50: Warning:Unterminated string constant
indent: foo.c:71: Warning:Unterminated string constant
indent: foo.c:72: Warning:Unterminated string constant
indent: foo.c:97: Error:Unmatched 'else'
indent: foo.c:98: Warning:Unterminated string constant
indent: foo.c:99: Warning:Unterminated string constant
I removed conio.h and process.h, changed void main to int main(void) and
removed the remainder of any line beginning //. I spliced broken string
literals. I changed the randomize() call to srand(0), and I provided a
random() function:
int random(int max)
{
return max * (rand() / (RAND_MAX + 1.0));
}
I moved int i; from where it is now to the definitions section at the
top of main, to join x[4], check, etc. I removed int from for(int count
and instead defined count alongside i at the top of the function. Same
for the m-loop and n-loop a few lines further on. And since we already
had an i, I simply dropped int from int i in a loop a few lines further
on still.
I removed the call to getch, since there is no such function. I removed
k's definition, since it is never used. I added the statement:
return 0;
to the end of main. Since the file scope object named 'no' was never
used, I removed it. That's a poor name for an object, by the way. Think
about how easy it would be to misunderstand what it means.
With these fairly minimal changes, I compiled the program, and ran it.
Here is the output I got:
me@here> ./foo
7381 ----- This is a guessing game
------________________________________________***First read these
instructions***1.The number should be a 4 digit number without 0 in the
first place 2. The digit shouldn't be repeatedWant to play? (Y/N):
As you can see, some work remains to be done, but at least it now
compiles.