Can't run this project! Help Solve it pls

Please help me solve this problem.
I think the problem is not declaring it or having it as a parameter.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//Main

#include <iostream>
using namespace std;
#include <string>

void Menu_Option();
void Read_Lyric_File();

int main()
{
     int LyricNo;;
     
     Menu_Option();
     
     cout<<"Enter the lyrics number: ";
     cin>>LyricNo;
     
     Read_Lyric_File();
          
     system ("PAUSE");
     return 0;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//MainMenu

#include <iostream>
using namespace std;

void Menu_Option()
{
     cout<<"============================================================"<<endl;
     cout<<"=============ALOHA! WELCOME TO HOT MUSIC LYRICS============="<<endl;
     cout<<"============================================================"<<endl;
     cout<<"=                                                          ="<<endl;
     cout<<"=            01-EAGLES – HOTEL CALIFORNIA                  ="<<endl;
     cout<<"=            02-AWIE - DI PENJARA JANJI                    ="<<endl;
     cout<<"=            03-ACHIK & NANA - MEMORI BERKASIH             ="<<endl;
     cout<<"=            04-LENKA - TROUBLE IS A FRIEND                ="<<endl;
     cout<<"=            05-KELLY CLARKSON - WHAT DOESN'T KILL YOU     ="<<endl;
     cout<<"=                                                          ="<<endl;
     cout<<"============================================================"<<endl;
     cout<<"======================ENJOY THE LYRICS======================"<<endl;
     cout<<"============================================================"<<endl;
    
}


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
//ReadLyric

#include <iostream>
#include <fstream>
#include <string>


using namespace std;

void Read_Lyric_File()
{
     string line; 
     
     if(LyricNo==01)
     {
     ifstream myfile ("Eagles – Hotel California.txt");
     if (myfile.is_open())
     {    
         while (myfile.good())
         {
               getline (myfile,line);
               cout<<line<<endl;
         }
         myfile.close();
    }
}
    else if(LyricNo==02)
    {
         ifstream myfile("Awie - Di Penjara Janji.txt");
         if (myfile.is_open())
     {    
         while (myfile.good())
         {
               getline (myfile,line);
               cout<<line<<endl;
         }
         myfile.close();
    }
}
    else if(LyricNo==03)
    {
         ifstream myfile("Achik & Nana - Memori Berkasih.txt");
         if (myfile.is_open())
     {    
         while (myfile.good())
         {
               getline (myfile,line);
               cout<<line<<endl;
         }
         myfile.close();
    }
}
    else if(LyricNo==04)
    {
         ifstream myfile("LENKA - TROUBLE IS A FRIEND.txt");
         if (myfile.is_open())
     {    
         while (myfile.good())
         {
               getline (myfile,line);
               cout<<line<<endl;
         }
         myfile.close();
    }
}
    else if(LyricNo==05)
    {
         ifstream myfile("KELLY CLARKSON - WHAT DOESN'T KILL YOU.txt");
         if (myfile.is_open())
     {    
         while (myfile.good())
         {
               getline (myfile,line);
               cout<<line<<endl;
         }
         myfile.close();
    }
}
    else
    cout<<"LOL"<<endl;
    
    
}
Last edited on
- Explain your problem properly.
- Put your code in code tags otherwise you are not going to get much responses. Code without code tags looks like Chinese.. :D
done help pls
You still haven't explained what the problem is. Just from looking though, I think the problem is because you use LyricNo in your Read_Lyric_File function without declaring it or having it as a parameter.

Change the function prototype and definition to Read_Lyric_File(int LyricNo) and the function call to Read_Lyric_File(LyricNo).
i also don't know what the problem is. fg109 can you explain with detail. i think that is my problem
fg109 i try already but still can't run.
Whats the error saying? What line is it at?
closed account (3qX21hU5)
Change your function definition and declaration to.

void Read_Lyric_File(int LyricNo)


call your function in main like

/Main

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
using namespace std;
#include <string>

void Menu_Option();
void Read_Lyric_File();

int main()
{
     int LyricNo;;
     
     Menu_Option();
     
     cout<<"Enter the lyrics number: ";
     cin>>LyricNo;
     
     Read_Lyric_File(LyricNo);
          
     system ("PAUSE");
     return 0;
}


I would also suggest you change either your Variable name or parameter name so they are not the same but that is up to you.
i can run it but later the program not responding.
closed account (3qX21hU5)
Again you are giving us no information. You need to be detailed on your questions and about the descriptions of what is going wrong. Just saying the program is not responding isn't telling us much... How is it not responding?
" myfile.exe has stopped working"
"Windows is checking for a solution to the problem"

the program can run later pop-up above statement then the program automatic close.
i dont know what problem
Can anyone help me with this?
just solve my problem at //Main and //Read lyric.

i'm new in c++ and i'm using window 8. dev c++ cant run stable in window 8
Topic archived. No new replies allowed.