i have wriiten a program and i have encountered errors which i couldnt solve

i get some errors please help mee.....

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
  #include<iostream>
#include<conio.h>
#include<stdio.h>
using namespace std;
struct addr
        {
	int classroom;
	int floor;
	char section[10];
        };
struct club
        {
	int cno;
	char clubname[30];
	char leader_name[20];
	addr location;
	int nomem;
        };
	club clubno[10];
	int display(int infinity);
	int read();
	int n;
	int main( )
        {
	int pwd;
	cout<<"enter password"<<endl;
	cin>>pwd;
switch(pwd)
        {
	case'1532':
	cout<<"wrong password"<<endl;
 	break;
default:
	cout<<"wrong password"<<endl;
	case'54321':
        {
	cout<<"welcome user"<<endl;
	int noclub;
	char ch;
	cout<<"enter no of clubs";
	cin>>n;
	read( );
	do
        {
	cout<<"enter club no to display information"<<endl;
	cin>>noclub;
	int flag=0;
		for(int i=0;i<10;i++)
        {
	if(clubno[i],cno==noclub)
         {
	display(int i)
	flag=1;
	break;
          }
}
   	if(flag==0)
	cout<<"wrong club number\n";
	cout<<"do you want to continue?\n";
	cin>>ch;
         }
	while(ch=='y');
}
	int read( )
	for (int i=o;i<0;i++)
         {
	cout<<"enter club number"<<endl;
	cin>>clubno[i].cno;
	cout<<"enetr club name"<<endl;
	cin>>clubno[i].clubname;
	cin>>clubno[i]i.leader_name;
	couy>>"enter the number of member"<<endl;
	cin>>club[i].nomem;
	cout<<"club location\n";
	cout<<"enter the floor on which the club meeting is located"<<endl;
	cin>>clubno[i].location.floor;
	cout<<"enter the classroom in which the clubmeeting is located"<<endl;
	cin>>clubno[i].location.classroom;
	cout<<"enter the section of the classroom"<<endl;
	cin>>clubno[i].location.section;
	}
           
	int display(int a)
           {
	cout<<"club data\n";
	cout<<"club number"<<clubno[a].cno;
	cout<<"\n name of club:";
	cout.write(clubno[a].clubnmae;30;
	cout<<"\n leader name:";
	cout,write(clubno[a].leader_name;20);
	cout<<"\n number of members:";
	cout<<clubno[i].nomem;
	cout<<"location of club"<<endl;
	cout<<"class"<<clubno[a].location.classroom;
	cout<<"-"<<club[a].location.section;
	cout<<"\n floor no:"<<clubno[a].location.floor;
	}
	getch;
}



errors:
* multi_ character constant
* character constant too long for its type
*in function 'int main()'
*'cno' was not declared in this scope
*expected primary-expression before 'int'
*expected initializer before 'for'
*'i was not declared in this scope
*a function-definition is not allowed here before'{'token
*expected'}' at end of input
Last edited on
Thankyou for not telling us anything at all about the errors. You have correctly determined that the less information you give us, the more able we are to help figure out the problem.

[/sarcasm]
@mikeyboy i have now mentioned the errors
Hello jebin,

Welcome to the forum.

It would be helpful if you would post the actual error messages that you received instead of making everyone guess what is wrong.

It could be your copy and past may have missed the closing } of main. Or it was never there to begin with.

Line 21 does not find the function definition for "Read()".

The switch/case is all wrong. You can only switch on an int or char. your case statement of case'1532': should be case 1532:. Notice the space betewn "case" and the number and the use of single quotes is for a character which means only one character. "defaule" should be the last part of the case statements.

Line 50 "cno" is undefined.

Line 52 You do not need the "int" before "i" and you are missing a ;.

Line 64 is almost a prototype, but not a function call.

Line 98 will not work the way it is written. Did you mean "getch()"?

An error for line 72 should be telling you that something is misspelled.

You have a good start, but yur indenting could be better. For an example:

Your code:
1
2
3
4
5
6
struct addr
        {
	int classroom;
	int floor;
	char section[10];
        };


Would look better as:
1
2
3
4
5
6
struct addr
{
	int classroom;
	int floor;
	char section[10];
};

I know that the indenting here is a bit more then normal, but you get the idea.

I would replace any character arrays with std::string (header file <string>).

The use of "conio.h" may be usable for you, but not everyone has this header file to use. And it is not a standard C++ header file.

"cstdio" would be a better choice over "stdio.h".

You should learn not to use using namespace std;. This WILL get you in trouble some day.

Hope that helps,

Andy
Topic archived. No new replies allowed.