Hi all,

I am trying to write a CWEB c++ program that just keepsgoing until the user types 'no'. Anyway i get some errors that I can't fix.

Here is the .w file (x's are comment blocks to save congestion)

@* Program Skeleton

@ x


@c
using namespace std;@;
@<Header files@>@;
@<The main program@>@;

@ x

@<Header files@>=
#include <iostream>
#include <fstream>

@* x

@<The main program@>=
int main()
{
   @<Variables of main@>@;
   do {
      @<Check play again@>@;
   } while(continue != "No");

   return 0;
}

@ x

@<Check play again@>=
cout << "Do you want to play again? ";
cin >> continue;

@ x

@<Variables of main@>=
char continue[3];

@ x

The errors i get are:

ctangle test.w
g++ test.c
./test.w: In function ‘int main()’:
./test.w:40:6: error: expected unqualified-id before ‘continue’
./test.w:34:6: error: expected primary-expression before ‘continue’
./test.w:34:6: error: expected ‘;’ before ‘continue’
./test.w:25:8: error: expected primary-expression before ‘continue’
./test.w:25:8: error: expected ‘)’ before ‘continue’
./test.w:25:8: error: expected ‘;’ before ‘continue’
./test.w:25:8: error: continue statement not within a loop
./test.w:25:16: error: expected ‘;’ before ‘!=’ token
./test.w:25:16: error: expected primary-expression before ‘!=’ token
./test.w:25:22: error: expected ‘;’ before ‘)’ token

No idea what they are asking me to do.

Here is the .c file

/*2:*/
#line 6 "./test.w"

using namespace std;
/*3:*/
#line 13 "./test.w"

#include <iostream> 
#include <fstream> 

/*:3*/
#line 8 "./test.w"

/*4:*/
#line 19 "./test.w"

int main()
{
/*6:*/
#line 39 "./test.w"

char continue[3];

/*:6*/
#line 22 "./test.w"

do{
/*5:*/
#line 32 "./test.w"

cout<<"Do you want to play again? ";
cin>>continue;

/*:5*/
#line 24 "./test.w"

}while(continue!="No");

return 0;
}

/*:4*/
#line 9 "./test.w"


/*:2*/

Continue is a reserved keyword in C and C++, so give your char array a different name.

AHAHAHAHA. THanks so much mate. What a lame error. I would have never got that.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.