Error "a function-definition is not allowed here before "{" token" Help?

{for(int x=55;x<=60;x++)
{gotoxy(x,y);color(0x9f);cout<<" ";}}
}
void loading() //loading screen
{gotoxy(11,30);color(0xB9);cout<<" This program is made specifically for BSCE students of";
gotoxy(11,32);color(0xB9);cout<<" National-University Philippines. All rights reserved";
for(int x=15;x<=60;x++)
{Sleep(90);
gotoxy(x,35);color(0x9e);cout<<" ";}
system("cls");
}

I always get the error message.
#include<iostream>
#include<conio.h>
#include<fstream>

#include<string.h>
#include<cstdlib>
#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <fstream>
#include <vector>
#include <iostream>
#include <sstream>
#include<iostream>
#include<conio.h>
#include<windows.h>
#include<iomanip>


using namespace std;
string _DATE_,_TIME_;

void frontpage();
void loading();
void grading();
void newstu();
void gotoxy(int x,int y)
{
COORD coord;
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
void color(int z)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),z);
}

main()
{frontpage();
loading();
int oldnew;
color(0Xb0);gotoxy(20,20);cout<<" ";
color(0xb0);gotoxy(20,21);cout<<" ARE YOU AND OLD OR A NEW STUDENT? ";
color(0xb0);gotoxy(20,22);cout<<" ";
color(0xb0);gotoxy(20,23);cout<<" ";
color(0xb0);gotoxy(37,23);cout<<" ";
color(0xb0);gotoxy(20,24);cout<<" <1> NEW ";
color(0xb0);gotoxy(37,24);cout<<" <2> OLD ";
color(0xb0);gotoxy(20,25);cout<<" ";
color(0xb0);gotoxy(37,25);cout<<" ";
color(0xb0);gotoxy(20,26);cout<<" ";
color(0xb0);gotoxy(20,27);cout<<" ";

color(0xb0);gotoxy(36,27);cin>>oldnew;
system("cls");
if(oldnew==1)newstu();
if(oldnew==2)grading();
getch();
}

void frontpage()//Homepage
{for(int y=0;y<=55;y++) //background
{for(int x=0;x<=78;x++) {color(0xB0);cout<<"";
cout<<endl;}
gotoxy(1,1);cout<<_DATE_; //date
gotoxy(70,1);cout<<_TIME_; //time
for(int y=8;y<=21;y++) //N left part
{for(int x=16;x=20;x++)
{gotoxy(x,y);color(0x9f);cout<<" ";}}
gotoxy(21,9);color(0x9f);cout<<" ";
gotoxy(21,10);color(0x9f);cout<<" ";
gotoxy(21,11);color(0x9f);cout<<" ";
gotoxy(21,12);color(0x9f);cout<<" ";
gotoxy(22,13);color(0x9f);cout<<" ";
gotoxy(23,14);color(0x9f);cout<<" ";
gotoxy(24,15);color(0x9f);cout<<" ";
gotoxy(25,16);color(0x9f);cout<<" ";
gotoxy(26,17);color(0x9f);cout<<" ";
gotoxy(27,18);color(0x9f);cout<<" ";
gotoxy(28,19);color(0x9f);cout<<" ";
gotoxy(29,20);color(0x9f);cout<<" ";
gotoxy(30,21);color(0x9f);cout<<" ";
for(int y=8;y<=21;y++) //IN right part
{for(int x=31;x<=35;x++)
{gotoxy(x,y);color(0x9f);cout<<" ";}}
for(int y=8;y<=18;y++) //U left part
{for(int x=40;x<=45;x++)
{gotoxy(x,y);color(0x9f);cout<<" ";}}
gotoxy(41,19);color(0x9f);cout<<" "; //U down part
gotoxy(55,19);color(0x9f);cout<<" ";
gotoxy(32,20);color(0x9f);cout<<" ";
gotoxy(44,21);color(0x9f);cout<<" ";
for(int y=8;y<=18;y++) //U right part
{for(int x=55;x<=60;x++)
{gotoxy(x,y);color(0x9f);cout<<" ";}}
}
void loading() //loading screen
{gotoxy(11,30);color(0xB9);cout<<" This program is made specifically for BSCE students of";
gotoxy(11,32);color(0xB9);cout<<" National-University Philippines. All rights reserved";
for(int x=15;x<=60;x++)
{Sleep(90);
gotoxy(x,35);color(0x9e);cout<<" ";}
system("cls");
}
void newstu()
{
char name[30],stunum[30],uname[30],pw[30],dummy[30];
cin.getline(dummy,30);
ofstream outfile;

for(int x=20;x<=53;x++) {gotoxy(x,20);color(0xe0);cout<<" ";}
for(int x=20;x<=53;x++) {gotoxy(x,21);color(0xe0);cout<<" ";}
for(int x=20;x<=53;x++) {gotoxy(x,22);color(0xe0);cout<<" ";}
//creataccount
gotoxy(27,21);cout<<"CREATE NEW ACCOUNT";
color(0xb0);
gotoxy(20,23);cout<<" Name ";
gotoxy(20,24);cout<<" ";
gotoxy(20,25);cout<<" Student number ";
gotoxy(20,26);cout<<" ";
gotoxy(20,27);cout<<" Username ";
gotoxy(20,28);cout<<" ";
gotoxy(20,29);cout<<" Password ";
gotoxy(20,30);cout<<" ";
gotoxy(27,23);cin.getline(name,30);
gotoxy(38,25);cin.getline(stunum,30);
gotoxy(31,27);cin.getline(uname,30);
gotoxy(31,29);cin.getline(pw,30);

Sleep(1000);
system("cls");
gotoxy(17,27);cout<<"Your account has been created. You can now log-in.";
Sleep(2000);

outfile.open(name);
outfile<<uname<<endl;
outfile<<pw<<endl;
outfile<<name<<endl;
outfile<<stunum<<endl;
outfile.close();

system("cls");
x:
//login
char uuname[30],ppw[30];
ifstream infile;
infile.open(name);
infile>>uname;
infile>>pw;
infile.close();


for(int x=20;x<=53;x++) {gotoxy(x,20);color(0xe0);cout<<" ";}
for(int x=20;x<=53;x++) {gotoxy(x,21);color(0xe0);cout<<" ";}

gotoxy(27,21);cout<<"LOG-IN";
color(0xB0);

gotoxy(20,23);cout<<"Username: ";
gotoxy(20,24);cout<<" ";
gotoxy(20,25);cout<<"Password: ";
gotoxy(20,26);cout<<" ";

gotoxy(31,23);cin.getline(uuname,30);
gotoxy(31,25);cin.getline(ppw,30);

if(strcmp(uname,uuname)==0)
{if(strcmp(pw,ppw)!=0)
{system("cls");cout<<"Incorrect username or password. Please try again. \n"<<endl;Sleep(1000);
system("cls"); goto x;}
Sleep(3000);
system("cls");


gotoxy(5,3);cout<<"Flowcode: 1-2010-BSCE"; //top part
gotoxy(5,4);cout<<"Flow Name: CURRICULUM FOR BACHELOR OF SCIENCE IN CIVIL ENGINEERING"; //top part
gotoxy(5,5);cout<<"Course: BSCE"; //top part


gotoxy(5,7);cout<<"Subjects to be taken:\n";
cout<<" Subject Code: Subject:\n";
cout<<" HENGC01 | English Communication 1\n";
cout<<" HFILKOM | Komunikasyon sa Akademikong Filipino\n";
cout<<" FCOLAL7 | College Algebra\n";
cout<<" FPSTRIG | Plane and Spherical Trigonometry\n";
cout<<" FGNCNM | General Chemistry\n\n";

cout<<" Miscellaneous: \n";
cout<<" Registration Fee P 11,130.00\n";
cout<<" Library Fee 899.00\n";
cout<<" Student Activity Fee 222.20\n";
cout<<" Atheltic Development Fee 279.00\n";
cout<<" Medical and Dental Fee 202.00\n";
cout<<" Audio Visual Fee 263.00\n";
cout<<" Academic Community Advancement Fee 334.00\n";
cout<<" Cultural Fee 246.00\n";
cout<<" Guidance Counselling Fee 230.00\n";
cout<<" Development Fee 1,894.00\n";
cout<<" Internet Fee 361.00\n";
cout<<" Testing Materials Fee 202.00\n";
cout<<" Insurance Fee 56.00\n";
cout<<" Energy Fee 2,541.00\n";
cout<<" TOTAL PAYMENT: P 31,954";
}
void grading()
}int inYear,inSem;
string username;
string password;

x:
for(int x=20;x<=53;x++) {gotoxy(x,20);color(0xe0);cout<<" ";}
for(int x=20;x<=53;x++) {gotoxy(x,21);color(0xe0);cout<<" ";}
for(int x=20;x<=53;x++) {gotoxy(x,22);color(0xe0);cout<<" ";}
gotoxy(20,22);cout<< " LOG-IN ";
color(0xf0);
gotoxy(20,23);cout<<" Username ";
gotoxy(20,24);cout<<" ";
gotoxy(20,25);cout<<" Password ";
gotoxy(20,26);cout<<" ";
gotoxy(33,23);cin>>username;
gotoxy(33,25);cin>>password;
if(username=="Zarah" && password=="Ferrer") {cout<<"Welcome to National University Enrollment Assessment System\n";system("cls");}
else if(username=="JC" && password=="Cheng") {cout<<"Welcome to National University Assessment System\n";system("cls"):}
else if(username=="Javen" && password=="Taal") {cout<<"Welcome to National University Assessment System\n";system("cls"):}
else if(username=="Adriel" && password=="Bellosillo") {cout<<"Welcome to National University Assessment System\n";system("cls"):}
else{cout<<"Incorrect username or password. Please try again."<<"\n"<<endl;
system("cls");goto x;
system("cls");
x:
//login
char uuname[30],ppw[30];
ifstream infile;
infile.open(name);
infile>>uname;
infile>>pw;
infile.close();


for(int x=20;x<=53;x++) {gotoxy(x,20);color(0xe0);cout<<" ";}
for(int x=20;x<=53;x++) {gotoxy(x,21);color(0xe0);cout<<" ";}

gotoxy(27,21);cout<<"LOG-IN";
color(0xB0);

gotoxy(20,23);cout<<"Username: ";
gotoxy(20,24);cout<<" ";
gotoxy(20,25);cout<<"Password: ";
gotoxy(20,26);cout<<" ";

gotoxy(31,23);cin.getline(uuname,30);
gotoxy(31,25);cin.getline(ppw,30);

if(strcmp(uname,uuname)==0)
{if(strcmp(pw,ppw)!=0)
{system("cls");cout<<"Incorrect username or password. Please try again. \n"<<endl;Sleep(1000);
system("cls"); goto x;}
Sleep(3000);
system("cls");


gotoxy(5,3);cout<<"Flowcode: 1-2010-BSCE"; //top part
gotoxy(5,4);cout<<"Flow Name: CURRICULUM FOR BACHELOR OF SCIENCE IN CIVIL ENGINEERING"; //top part
gotoxy(5,5);cout<<"Course: BSCE"; //top part


gotoxy(5,7);cout<<"Subjects to be taken:\n";
cout<<" Subject Code: Subject:\n";
cout<<" HENGC01 | English Communication 1\n";
cout<<" HFILKOM | Komunikasyon sa Akademikong Filipino\n";
cout<<" FCOLAL7 | College Algebra\n";
cout<<" FPSTRIG | Plane and Spherical Trigonometry\n";
cout<<" FGNCNM | General Chemistry\n\n";

cout<<" Miscellaneous: \n";
cout<<" Registration Fee P 11,130.00\n";
cout<<" Library Fee 899.00\n";
cout<<" Student Activity Fee 222.20\n";
cout<<" Atheltic Development Fee 279.00\n";
cout<<" Medical and Dental Fee 202.00\n";
cout<<" Audio Visual Fee 263.00\n";
cout<<" Academic Community Advancement Fee 334.00\n";
cout<<" Cultural Fee 246.00\n";
cout<<" Guidance Counselling Fee 230.00\n";
cout<<" Development Fee 1,894.00\n";
cout<<" Internet Fee 361.00\n";
cout<<" Testing Materials Fee 202.00\n";
cout<<" Insurance Fee 56.00\n";
cout<<" Energy Fee 2,541.00\n";
cout<<" TOTAL PAYMENT: P 31,954";
}
void grading()
}int inYear,inSem;
string username;
string password;

x:
for(int x=20;x<=53;x++) {gotoxy(x,20);color(0xe0);cout<<" ";}
for(int x=20;x<=53;x++) {gotoxy(x,21);color(0xe0);cout<<" ";}
for(int x=20;x<=53;x++) {gotoxy(x,22);color(0xe0);cout<<" ";}
gotoxy(20,22);cout<< " LOG-IN ";
color(0xf0);
gotoxy(20,23);cout<<" Username ";
gotoxy(20,24);cout<<" ";
gotoxy(20,25);cout<<" Password ";
gotoxy(20,26);cout<<" ";
gotoxy(33,23);cin>>username;
gotoxy(33,25);cin>>password;
if(username=="Zarah" && password=="Ferrer") {cout<<"Welcome to National University Enrollment Assessment System\n";system("cls");}
else if(username=="JC" && password=="Cheng") {cout<<"Welcome to National University Assessment System\n";system("cls"):}
else if(username=="Javen" && password=="Taal") {cout<<"Welcome to National University Assessment System\n";system("cls"):}
else if(username=="Adriel" && password=="Bellosillo") {cout<<"Welcome to National University Assessment System\n";system("cls"):}
else{cout<<"Incorrect username or password. Please try again."<<"\n"<<endl;
system("cls");goto x;
}

//subject/grade input
color(0x97);
system("cls");
for(int y=18;y<=31;y++) //grid left part
{gotoxy(4,y);cout<<"|";)
for(int y=17;y<=73;x++){gotoxy(x,y);cout<<"_";}
cout<<endl;}
for(int y=18;y<=31;y++) //grid right part
{gotoxy(74,y);cout<<"|";}
for(int y=18;y<=29;y++) //grid 2nd vertical part
{gotoxy(13;y);cout<<"|";}
for(int y=18;y<=31;y++) //grid 3rd vertical part
{gotoxy(53,y);cout<<"|";}
for(int y=18;y<=31;y++) //grid 4th vertical part
{gotoxy(60;y);cout<<"|";}
for(int y=20;y<=29;y++) //grid 5th vertical part
{gotoxy(67,y);cout<<"|";}

//grading equivalent

for(int y=9;y<=16;y+=6) //grid horizontal part
{for(int x=5;x<=73;x++){gotoxy(x,y);cout<<"_";}}
for(int x=5;x<=73;x++){gotoxy(x,y);cout<<"_";} //grid horizontal part
for(int y=10;y<=15;y++) //grid 1st vertical part
{gotoxy(4,y);cout<<"|";}
for(int y=10;y<=15;y++) //grid 2nd vertical part
{gotoxy(74,y);cout<<"|";}

gotoxy(35,10);cout<<"REMARKS";
gotoxy(6,12);cout<<" USE ONLY PERCENTAGE (%) GRADING SYSTEM IN INPUTTING YOUR GRADES";
gotoxy(6,13);cout<<" 96-100= 4"; gotoxy(20,13);cout<<"87-90= 3";
gotoxy(6,14);cout<<" 91-95 = 3.5";gotoxy(20,14);cout<<"84-86= 2.5";
gotoxy(34,13);cout<<" 81-83 = 2";gotoxy(35,14);cout<<"78-80= 1.5";
gotoxy(48,13);cout<<" 75-77 = 1";gotoxy(49,14);cout<<">75 = 1.5";
gotoxy(62,13);cout<<" INC = 101"; gotoxy(63,14);cout<<"DROPPED=2";


//top part
gotoxy(5,1);cout<<"Name:"<<password<<","<<username; //must be (name)
gotoxy(5,3);cout<<"Flowcode: 1-2010-BSCE"; //top part
gotoxy(5,4);cout<<"Flow Name: CURRICULUM FOR BACHELOR OF SCIENCE IN CIVIL ENGINEERING"; //top part
gotoxy(5,5);cout<<"Course: BSCE"; //top part

gotoxy(5,18);cout<<"SUB CODE";
gotoxy(19,18);cout<<"SUBJECT DESCRIPTION";
gotoxy(54,18);cout<<"UNITS";
gotoxy(61,18);cout<<"GRADES";
gotoxy(14,30);cout<<"TOTAL UNITS";



gotoxy(5,8);cout<<"Enter Year";
cin>>inYear;
gotoxy(30,8);cout<<"Enter Semester";
cin>>InSem;

if(inYear==1&&inSem==1)
{
system("cls");
gotoxy(5,1);cout<<"Name:"<<password<<","<<username; //must be (name)
gotoxy(5,3);cout<<"Flowcode: 1-2010-BSCE"; //top part


gotoxy(5,7);cout<<"Subjects to be taken:\n";
cout<<"SUBJECT CODE: Subject:\n";
cout<<"HENGCO1 | English Communication 1\n";
cout<<"HFILKOM | Komunikasyon sa Akademikong Filipino\n";
cout<<"FCOLAL7 | College Algebra\n";
cout<<"FPSTRIG | Plane and Spherical Trigonometry\n";
cout<<"FGENCNM | General Chemistry\n\n";

cout<<" Miscellaneous: \n";
cout<<" Registration Fee P11,130.00\n";
cout<<" Library Fee 899.00\n";
cout<<" Student Activity Fee 222.00\n";
cout<<" Athletic Development Fee 279.00\n";
cout<<" Medical and Dental Fee 202.00\n";
cout<<" Audio Visual Fee 263.00\n";
cout<<" Academic Community Advancement Fee 334,00\n";
cout<<" Cultural Fee 246.00\n";
cout<<" Guidance Counselling Fee 230.00\n";
cout<<" Development Fee 1,894.00\n";
cout<<" Internet Fee 361.00\n";
cout<<" Testing Materials Fee 202.00\n";
cout<<" Insurance Fee 56.00\n";
cout<<" Student Activity Fee 279.00\n";
cout<<" Student Activity Fee 279.00\n";
cout<<" Student Activity Fee 279.00\n";
cout<<" Student Activity Fee 279.00\n";
cout<<" Student Activity Fee 279.00\n";
cout<<" Energy Fee 2,541.00\n";
cout<<" TOTAL PAYMENT: P31,954";}
{
double a=3,a1;
double b=3,b1;
double c=3,c1;
double d=3,d1;
double e=3,e1;

gotoxy(5,20);cout<<"HENGC01"; gotoxy(14,20);cout<<"ENGLISH COMMUNICATION 1";
gotoxy(5,22);cout<<"HFILKOM"; gotoxy(14,22);cout<<"KOMUNIKASYON SA AKADEMIKONG PILIPINO";
gotoxy(5,24);cout<<"FCOLAL7"; gotoxy(14,24);cout<<"COLLEGE ALGEBRA";
gotoxy(5,26);cout<<"FPSTRIG"; gotoxy(14,26);cout<<"PLANE AND SPHERICAL TRIGONOMETRY";
gotoxy(5,28);cout<<"FGENCNM"; gotoxy(14,28)l;cout<<"GENERAL CHEMISTRY";

gotoxy(56,20);cout<<a;
gotoxy(56,22);cout<<b;
gotoxy(56,24);cout<<c;
gotoxy(56,26);cout<<d;
gotoxy(56,28);cout<<e;

gotoxy(55,30);cout<<a+b+c+d+e;

gotoxy(62,20);cin>>a1;



return 0;
system ("Pause");
}
I only get two errors.

1. [Error] a function-definition is not allowed here before '{' token

2. [Error] expected '}' at end of input
Its an enrollment system advising. We just have to copy it from a book. It's an advising system for students who wants to enroll. I just need to fix these errors. Appreciate your help.
Last edited on
Thank you.
I posted it. Right here. http://textuploader.com/5888r
I only get two errors.

1. [Error] a function-definition is not allowed here before '{' token

2. [Error] expected '}' at end of input

The compiler should also mention the line of code, where the error seems to occur. (Trivial for the latter "at the end of file" error, but crucial for the first error.)

On the first error the compiler has stumbled on '{' where it did not expect. Which '{' of your code is it and what is before it? (The "before" could be on multiple lines.)

The second error indicates an unpaired '{'. The compiler has seen an open scope {, then waded through the content of the scope until it did hit EOF, rather than a closing }.
UNIX/Linux Programming
Programming C++ for UNIX and Linux
#include <conio.h>
.oi
If the parser fails to find a closing delimiter before the end-of-file, there is something mismatched.

You can often find this sort of problem by indenting your code. By not indenting your program, you make it artificially difficult to read and to follow -- and since studies have shown that you spend about 90% of your time reading your code, being able to read it is important.

In your program, find
1
2
void grading() 
      }int inYear,inSem;

You are missing (at least) a single opening brace following the function declaration.
Last edited on
Topic archived. No new replies allowed.