Error: Expected unqualified-id before '{' token

Need help with a really simple program

Page 1 of 1

4 Replies - 6423 Views - Last Post: 09 April 2009 - 11:51 PM Rate Topic: -----

#1 tomfable  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 07-April 09

Error: Expected unqualified-id before '{' token

Posted 09 April 2009 - 11:09 AM

Hey all, I need some help with compiling a program.

Here's the code:
-----------------------------------------------------------------------
#include <iostream>

using namespace std;

int Rode()

{
for( int i = 0; i < 1000; i++ );
}

{
    cout<<"  ##            |  |            ##\n";
    cout<<"  ##            |  |            ##\n";
    cout<<"  ##            |  |            ##\n";
    cout<<"  ##            |  |            ##\n";
    cout<<"  ##            |  |            ##\n";
    cout<<"  ##            |  |            ##\n";
    cout<<"  ##            |  |            ##\n";
    cout<<"  ##            |  |            ##\n";

    Rode();
}

-----------------------------------------------------------------------
The result is: Error: excpected unqualified-id before '{' token
Any help, please?

*** MOD EDIT: Added code tags, removed extra code post. Please :code: ***

This post has been edited by JackOfAllTrades: 09 April 2009 - 12:16 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Error: Expected unqualified-id before '{' token

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,516
  • Joined: 23-August 08

Re: Error: Expected unqualified-id before '{' token

Posted 09 April 2009 - 12:18 PM

You have no main, and a loop that does nothing. Not even sure what you're trying to accomplish here.
Was This Post Helpful? 0
  • +
  • -

#3 IrishCereal  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 81
  • Joined: 11-December 08

Re: Error: Expected unqualified-id before '{' token

Posted 09 April 2009 - 12:32 PM

Not that it will do anything, but if you want it to compile make it looks like this:

#include <iostream>

using namespace std;

int main() {

for( int i = 0; i < 1000; i++ ) {
}

	cout<<"  ##			|  |			##\n";
	cout<<"  ##			|  |			##\n";
	cout<<"  ##			|  |			##\n";
	cout<<"  ##			|  |			##\n";
	cout<<"  ##			|  |			##\n";
	cout<<"  ##			|  |			##\n";
	cout<<"  ##			|  |			##\n";
	cout<<"  ##			|  |			##\n";

	return 0;
}



Haha..

Maybe you want something like this:
#include <iostream>
using namespace std;

int main(void) {
  cout<<"  ##			|  |			##" << endl;
  cout<<"  ##			|  |			##" << endl;
  cout<<"  ##			|  |			##" << endl;
  cout<<"  ##			|  |			##" << endl;
  cout<<"  ##			|  |			##" << endl;
  cout<<"  ##			|  |			##" << endl;
  cout<<"  ##			|  |			##" << endl;
  cout<<"  ##			|  |			##" << endl;
  cout<<"  ##			|  |			##" << endl;
  return 0;
}


This post has been edited by IrishCereal: 09 April 2009 - 12:35 PM

Was This Post Helpful? 0
  • +
  • -

#4 tomfable  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 07-April 09

Re: Error: Expected unqualified-id before '{' token

Posted 09 April 2009 - 11:08 PM

OK look people, I changed the code a bit and it does compile, but it doesn't loop!
#include <iostream>

using namespace std;

int main() {

for( int i = 0; i < 65000; i++ ) {
}


	cout<<"  ##			|  |			##\n";
	cout<<"  ##			|  |			##\n";
	cout<<"  ##			|  |			##\n";
	cout<<"  ##			|  |			##\n";
	cout<<"  ##			|  |			##\n";
	cout<<"  ##			|  |			##\n";
	cout<<"  ##			|  |			##\n";
	cout<<"  ##			|  |			##\n";

	return 0;
}


Was This Post Helpful? 0
  • +
  • -

#5 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5313
  • View blog
  • Posts: 27,216
  • Joined: 10-May 07

Re: Error: Expected unqualified-id before '{' token

Posted 09 April 2009 - 11:51 PM

That's because there is nothing in your loop.

#include <iostream>

using namespace std;

int main() {
	for( int i = 0; i < 65000; i++ ) {
		// Start loop
		cout<<"  ##			|  |			##\n";
		cout<<"  ##			|  |			##\n";
		cout<<"  ##			|  |			##\n";
		cout<<"  ##			|  |			##\n";
		cout<<"  ##			|  |			##\n";
		cout<<"  ##			|  |			##\n";
		cout<<"  ##			|  |			##\n";
		cout<<"  ##			|  |			##\n";
	}
	return 0;
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1