Apr 20, 2013 at 6:13pm UTC
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 Apr 21, 2013 at 2:41am UTC
Apr 20, 2013 at 6:18pm UTC
- 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
Apr 20, 2013 at 7:16pm UTC
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)
.
Apr 21, 2013 at 2:08am UTC
i also don't know what the problem is. fg109 can you explain with detail. i think that is my problem
Apr 21, 2013 at 2:14am UTC
fg109 i try already but still can't run.
Apr 21, 2013 at 4:50am UTC
Whats the error saying? What line is it at?
Apr 21, 2013 at 7:52am UTC
i can run it but later the program not responding.
Apr 21, 2013 at 7:57am UTC
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?
Apr 21, 2013 at 10:10am UTC
" 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
Apr 21, 2013 at 10:51am UTC
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