do while compile error

Stumped as to why following code does not compile using MinGW.
Help would be significantly appreciated!!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <cctype>
using namespace std;

int main()
{
 	const int MaxLoopCnt = 4;
	int loopiteration = 0;

	do
	{
		++loopiteration;
	) 	while (loopiteration < MaxLoopCnt) ;  // this is ? the  err

		return 0;
}
I shortened the below complier messages:

 In function 'int main()':
cpp:16:2: error: expected primary-expression before ')' token
cpp:16:2: error: expected ';' before ')' token
cpp:19:1: error: expected 'while' at end of input
cpp:19:1: error: expected '(' at end of input
cpp:19:1: error: expected primary-expression at end of input
cpp:19:1: error: expected ')' at end of input
cpp:19:1: error: expected ';' at end of input
cpp:19:1: error: expected '}' at end of input
Process terminated with status 1 (0 minute(s), 0 second(s))
8 error(s), 0 warning(s) (0 minute(s), 0 second(s))

You simply put a ) instead of } before while
Here:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <cctype>
using namespace std;

int main()
{
 	const int MaxLoopCnt = 4;
	int loopiteration = 0;

	do
	{
		++loopiteration;
		std::cout << "Loop: " << loopiteration << "\n";
		
	} 	while(loopiteration != MaxLoopCnt); 

	return 0;
}
Last edited on
Topic archived. No new replies allowed.