/*
 USE IT HOWEVER YOU WANT :D
*/

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

using namespace std;


char name[100];
wchar_t words[100];
int choice;
int chmon;
int level;
int main (int argc, char *argv[])


{ //main

    string used("this game is cool");
    string in;

cout<<"Hello Welcome to the Code Game!"<<endl;    
cout<<"--------------x----------------"<<endl;
cout<<endl;
cout<<"Please enter yourname : ";
cin>>name;
cout<<endl;
cout<<"Welcome to the code game, ";
cout<<name<<endl;

cout<<"1. New game"<<endl;
cout<<"2. Level Select"<<endl;
cout<<"3. About"<<endl;
cout<<"--------------x----------------"<<endl;
cout<<endl;
cout<<"Please enter choice : "<<endl;
cin>>choice;

if (choice == 1)
{  
           cout<<endl;
           cout<<endl;
           cout<<"New game huh? Cool ! Let's start with some small codes!"<<endl;
           cout<<endl;
           cout<<endl;

           cout<<"1    2    3"<<endl;
           cout<<"ABC  DEF  GHI"<<endl;
           cout<<"4    5    6"<<endl;
           cout<<"JKL  MNO  PQR"<<endl;
           cout<<"7    8    9"<<endl;
           cout<<"STU  VXY  Z "<<endl;

           cout<<endl;
           cout<<endl;

           cout<<"I know there is no 'w' it is supposed to be like that."<<endl;
           cout<<endl;
           cout<<endl;
           cout<<"Try not to use Paper/Pen."<<endl;
           cout<<endl;
           cout<<endl;
           cout<<"Here is your first code : [7337] [3152] [37] [1554] "<<endl;
           cout<<endl;
           cout<<"The sentence is : ";
           getline(cin, in);
           getline(cin, in);
           cout<<endl;

           if (in == used)
           {
               cout<<"You're right! Congratulations!"<<endl;
               }

               else
               {
                   cout<<"You're wrong"<<endl;
                   }

               cout<<"Wanna try again? If yes Press '1' for Yes and '0' for no :"<<endl;


                                               cin>>chmon;
                                               if(chmon == 1)
                                               {
                                                        cout<<"Okay! Nice!"<<endl;

                                                        //Add game codes here! from text file! 


                                                        }                         

                                                        else 
                                                        {
                                                             cout<<"Okay then, Have a nice day!"<<endl;
                                                             system("start /MIN Soundtrack.mp3");
                                                             exit (EXIT_SUCCESS);
                                                             }                     
}

else if (choice == 2)
{//else if for real choice (2)
     cout<<"Please select Level from 1 - 25 !"<<endl;
     cout<<endl;
     cin>>level;

     } //else if for real choice (2)
else if(choice == 3)
{ //else if for real choice (3)
     cout <<"This game was made by HAYZAM "<<endl;
     }     //else if for real choice (3)
else 
{ //else for no real choice 
     cout << "Sorry this is not a real choice."<<endl;
     }    //else for no real choice 



system("PAUSE"); 
    return 0;
}   //main

Hey guys! This is the code that I've been working for the past couple of hours! What I need is that I want to read some text files and use them on the program, for example I want to give the user the code of the particular word.. not the word itself for this I need to output only some parts of a line in the text file, how will I do this? Thanks! Please check the text file that is attached..

Edited 2 Years Ago by Fazelessmetal

Attachments
WORDS              CODES

1.   Money              55529
2.   Bank               1154
3.   Balloon            1144555
4.   Sea                721
5.   water              81726
6.   Life               4322
7.   fire               2362
8.   Paper              61626
9.   game               3152
10.  Freedom            2622255
11.  Computer           15567726
12.  Mobile             551342
13.  Picture            6317762
14.  Music              57731
15.  Cinema             135251
16.  Radio              61235
17.  Skyview            7498328
18.  happiness          316635277
19.  Puzzle             679942
20.  Guitar             373716
21.  Stairway           77136819
22.  Heaven             321825
23.  Person             626755
24.  Crystal            1697714
25.  Addiction          122317355

I know how to take text from a file, but I have almost 120 of them now! How will I automate the process..? Can show me an example using a code? I want to display 1 text at a time, that too just half of the line! Each time the user inputs the correct code for the word it should move on to the next.

Edited 2 Years Ago by Fazelessmetal

This article has been dead for over six months. Start a new discussion instead.