help

Write your question here.can anyone corrert my program it has 37 errors :(


#include <iostream>
#include <string>
#include <ctype.h>
#include "conio.h"
using namespace std;


struct Politician;

{


char name[50];
char current_position[50];
char party_list[50];
char department[50];
char amatter;
char annual_salary[50];
char saln;
char known_as[50];
char religion[50];
char implemented_law[50];

}



void main()
{
int j;







Politician [] = {{"Rodrigo Roa Duterte","16th President of the Philippines" ,"PDP-LABAN,SENATE",1,"SAN BEDA","10M"",The Punisher","Deism","911 law";},
{"Defensor Miriam Santiago","Senator","INDEPENDENT","SENATE",250,"ATENEO",5,"iron fist","Roman Catholic","tax payer law";};
{"Grace Poe","Senator","INDEPENDENT","SENATE",150,"OXFORD UNIV",6,"grace","Roman Catholic","rep. act 2004";},
{"Francis Escudero","Senator","INDEPENDENT","SENATE",6"DLSU",7,"chiz","Roman Catholic","rep. act 1993";},
{"Vicente Sotto","Senator","LIBERAL","SENATE",45,"FEU",8,"tito","Roman Catholic","rep. act 1994";},
{"Pacquiao Manny","Senator","UNA","SENATE",45,"FEU",5,"pacman","Roman Catholic","rep. act 1996";},
{"Robredo Leni","16th V-president of the Philippines","LIBERAL","SENATE",1,"ATENEO",5,"leni","Roman Catholic","rep. act 2015";},
{"Drilon Franklin","Senate President","LIBERAL","SENATE",50,"ATENEO",5,"frank","Roman Catholic","rep. act 1990";},
{"Pimentel Aquilino III","Member of the Senate","PDP-LABAN","SENATE",45,"ATENEO",5,"nene","Roman Catholic","rep. act 1999";};,
{"Aquino Benigno III","15TH President of the Philippines","LIBERAL","SENATE",1,"ATENEO",5,"noynoy","Roman Catholic","rep. act 2013";}};



cout << "Name\t\tcurrent_position\tparty_list\tdepartment\tannual_salary\talma matter\tsaln\tknown_as\treligion\tYear implemented_law" << endl;

for (j = 0; j < 10; j++)




{
cout << Politician[i].name;<< "\t"<< Politician[i].current_position;<< "\t"<< Politician[i].party_list ;<< "\t\t" << Politician[i].department;<< "\t"
<< Politician[i].annual_salary; << "\t" << Politician[i].alma matter; << "\t" << Politician[i].saln ;<< "\t\t" << Politician[i].known_as ;<< "\t"
<< Politician[i].religion;<< "\t" << Politician[i].Year implemented_law;<< "\t";

cout << endl;
}

_getch();


}




}
Hi,
Firstly :
#include "conio.h"

==>
#include <conio.h>
Secondly, remove all semi-colons ( ; ) before the closing braces ( } ). Semi-colons after ( } ) are acceptable you don't remove it.

For example :
;};
i got it thank you but it always give me like these errors




Compiling...
record1.cpp
Z:\activity records\record1.cpp(9) : error C2447: missing function header (old-style formal list?)
Z:\activity records\record1.cpp(37) : error C2065: 'Politician' : undeclared identifier
Z:\activity records\record1.cpp(37) : error C2143: syntax error : missing ';' before '['
Z:\activity records\record1.cpp(39) : error C2143: syntax error : missing ';' before ','
Z:\activity records\record1.cpp(40) : error C2065: 'DLSU' : undeclared identifier
Z:\activity records\record1.cpp(40) : error C2143: syntax error : missing ';' before 'string'
Z:\activity records\record1.cpp(40) : error C2146: syntax error : missing ';' before identifier 'chiz'
Z:\activity records\record1.cpp(40) : error C2065: 'chiz' : undeclared identifier
Z:\activity records\record1.cpp(40) : error C2143: syntax error : missing ';' before 'string'
Z:\activity records\record1.cpp(40) : error C2146: syntax error : missing ';' before identifier 'Roman'
Z:\activity records\record1.cpp(40) : error C2065: 'Roman' : undeclared identifier
Z:\activity records\record1.cpp(40) : error C2146: syntax error : missing ';' before identifier 'Catholic'
Z:\activity records\record1.cpp(40) : error C2065: 'Catholic' : undeclared identifier
Z:\activity records\record1.cpp(40) : error C2143: syntax error : missing ';' before 'string'
Z:\activity records\record1.cpp(40) : error C2146: syntax error : missing ';' before identifier 'rep'
Z:\activity records\record1.cpp(40) : error C2065: 'rep' : undeclared identifier
Z:\activity records\record1.cpp(40) : error C2146: syntax error : missing ';' before identifier 'act'
Z:\activity records\record1.cpp(40) : error C2065: 'act' : undeclared identifier
Z:\activity records\record1.cpp(40) : error C2143: syntax error : missing ';' before 'constant'
Z:\activity records\record1.cpp(40) : error C2001: newline in constant
Z:\activity records\record1.cpp(40) : error C2143: syntax error : missing ';' before 'string'
Z:\activity records\record1.cpp(41) : error C2143: syntax error : missing ';' before ','
Z:\activity records\record1.cpp(42) : error C2143: syntax error : missing ';' before ','
Z:\activity records\record1.cpp(43) : error C2143: syntax error : missing ';' before ','
Z:\activity records\record1.cpp(44) : error C2143: syntax error : missing ';' before ','
Z:\activity records\record1.cpp(45) : error C2143: syntax error : missing ';' before ','
Z:\activity records\record1.cpp(58) : error C2109: subscript requires array or pointer type
Z:\activity records\record1.cpp(58) : error C2228: left of '.name' must have class/struct/union type
Z:\activity records\record1.cpp(58) : error C2143: syntax error : missing ';' before '<<'
Z:\activity records\record1.cpp(58) : error C2143: syntax error : missing ';' before '<<'
Z:\activity records\record1.cpp(58) : error C2143: syntax error : missing ';' before '<<'
Z:\activity records\record1.cpp(58) : error C2143: syntax error : missing ';' before '<<'
Z:\activity records\record1.cpp(59) : error C2143: syntax error : missing ';' before '<<'
Z:\activity records\record1.cpp(59) : error C2143: syntax error : missing ';' before '<<'
Z:\activity records\record1.cpp(59) : error C2143: syntax error : missing ';' before '<<'
Z:\activity records\record1.cpp(59) : error C2143: syntax error : missing ';' before '<<'
Z:\activity records\record1.cpp(60) : error C2143: syntax error : missing ';' before '<<'
Z:\activity records\record1.cpp(60) : error C2143: syntax error : missing ';' before '<<'
Z:\activity records\record1.cpp(74) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

record1.obj - 39 error(s), 0 warning(s)
You forgot to put a semi-colon ( ; ) after a struct definition.
1
2
3
4
5
6
7
8
9
10
11
12
13
struct Politician;
{
char name[50];
char current_position[50];
char party_list[50];
char department[50];
char amatter;
char annual_salary[50];
char saln;
char known_as[50];
char religion[50];
char implemented_law[50];
}; //This place, this place 
Does that help you? :)
#include <iostream>
#include <string>
#include <ctype.h>
#include <conio.h>
using namespace std;


struct Politician
{
char name[500];
char position[500];
char partylist[500];
char department[500];
char amatter[500];
int salary[500];
int saln;
char known[500];
char religion[500];
char law[500];





};



void main()
{
int j;

Politician bbb[] = {{"Rodrigo Roa Duterte","16th President","PDP-LABAN","SENATE",1,"SAN BEDA",10,"The Punisher","Deism","911 law";};
{"Defensor Miriam Santiago","Senator","INDEPENDENT","SENATE",250,"ATENEO",5,"iron fist","Roman Catholic","tax payer law";};
{"Grace Poe","Senator","INDEPENDENT","SENATE",150,"OXFORD UNIV",6,"grace","Roman Catholic","rep act 2004";};
{"Francis Escudero","Senator","INDEPENDENT","SENATE",6 ,DLSU",7 ,"chiz","Roman Catholic","rep act 1993";};
{"Vicente Sotto","Senator","LIBERAL","SENATE",45,"FEU",8,"tito","Roman Catholic","rep act 1994";};
{"Pacquiao Manny","Senator","UNA","SENATE",45,"FEU",5,"pacman","Roman Catholic","rep act 1996";};
{"Robredo Leni","16th V-president of the Philippines","LIBERAL","SENATE",1,"ATENEO",5,"leni","Roman Catholic","rep act 2015";};
{"Drilon Franklin","Senate President","LIBERAL","SENATE",50,"ATENEO",5,"frank","Roman Catholic","rep act 1990";};
{"Pimentel Aquilino III","Member of the Senate","PDP-LABAN","SENATE",45,"ATENEO",5,"nene","Roman Catholic","rep act 1999";};
{"Aquino Benigno III","15TH President of the Philippines","LIBERAL","SENATE",1,"ATENEO",5,"noynoy","Roman Catholic","rep act 2013";}};



cout <<"name\t\tposition\t\tpartylist\tdepartment\tamatter\tsalary\tsaln\tknown\treligion\tlaw" << endl;

for (j=0; j<10 ; j++);
{

cout << bbb[j].name << "\t\t" << bbb[j].position << "\t" << bbb[j].partylist << "\t\t" << bbb[j].department << "\t\t"
<< bbb[j].amatter << "\t\t" << bbb[j].salary << "\t\t" << bbb[j].saln << "\t\t" << bbb[j].known << "\t\t"
<< bbb[j].religion << "\t\t" << bbb[j].law << "\t";




{

cout << endl;
}

_getch();






}





this is how it looks now and so far it has 22 errors




--------------------Configuration: record1 - Win32 Debug--------------------
Compiling...
record1.cpp
Z:\activity records\record1.cpp(33) : error C2440: 'initializing' : cannot convert from 'char [13]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Z:\activity records\record1.cpp(33) : error C2440: 'initializing' : cannot convert from 'char [6]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Z:\activity records\record1.cpp(33) : error C2440: 'initializing' : cannot convert from 'char [8]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Z:\activity records\record1.cpp(33) : error C2059: syntax error : ';'
Z:\activity records\record1.cpp(34) : error C2447: missing function header (old-style formal list?)
Z:\activity records\record1.cpp(35) : error C2447: missing function header (old-style formal list?)
Z:\activity records\record1.cpp(36) : error C2447: missing function header (old-style formal list?)
Z:\activity records\record1.cpp(36) : error C2001: newline in constant
Z:\activity records\record1.cpp(46) : error C2143: syntax error : missing ';' before '<<'
Z:\activity records\record1.cpp(46) : error C2501: 'cout' : missing storage-class or type specifiers
Z:\activity records\record1.cpp(46) : error C2143: syntax error : missing ';' before '<<'
Z:\activity records\record1.cpp(48) : error C2143: syntax error : missing ';' before 'for'
Z:\activity records\record1.cpp(48) : error C2143: syntax error : missing ')' before ';'
Z:\activity records\record1.cpp(48) : error C2143: syntax error : missing ';' before '<'
Z:\activity records\record1.cpp(48) : error C2501: 'j' : missing storage-class or type specifiers
Z:\activity records\record1.cpp(48) : error C2143: syntax error : missing ';' before '<'
Z:\activity records\record1.cpp(48) : error C2143: syntax error : missing ';' before '++'
Z:\activity records\record1.cpp(48) : error C2501: 'j' : missing storage-class or type specifiers
Z:\activity records\record1.cpp(48) : error C2086: 'j' : redefinition
Z:\activity records\record1.cpp(48) : error C2143: syntax error : missing ';' before '++'
Z:\activity records\record1.cpp(48) : error C2059: syntax error : ')'
Z:\activity records\record1.cpp(49) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.

record1.obj - 22 error(s), 0 warning(s)
Line 29: main must return type int.

Lines 33-41: Don't use ;}; to separate your rows. Use },

Lines 33-41: Your initializers don't line up with your struct declaration.
 
{"Rodrigo Roa Duterte","16th President","PDP-LABAN","SENATE",1,"SAN BEDA",10,"The Punisher","Deism","911 law"}

Your declaration has 5 char arrays, an array of 500 ints (salary ???), an int and 3 more char arrays.
Your initializer has 4 char array, an int, a char array, another int, and 3 more char arrays.
The types of your initializers must line up with your struct declaration.

Line 36: You're missing an open quote around DSLU.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.


Last edited on
Topic archived. No new replies allowed.