Dear All
I would be very happy if you could help me!
I need to create a main() program which is be able to;

* reads in a list of words and their associated meanings from the
given test file(file.txt)(This file contains 10 lines)
* provide an interactive menu interface to find a ‘word’ and display
the meaning(s) of the searched ‘word’ if it exists. Make sure you
include all appropriate input data validation at the menu interface
and provide suitable messages for a successful or unsuccessful
search.

I need a scratch main program to get the idea of how to create a main driver function.
regards
Juniper

// outline

// #include statements here
// #define statements here
// global variables here
// function declarations here


int main (int argc, char* argv[])
{
   // variables local to main ()
   // more code
   return 0;
}

// functions go here

This is a vague skeleton. You're going to have to show some effort or ask a more specific question for a more detailed answer.

Thanks
But still I dont get that how to read the lines(string) from an external file " file.txt"
regards

Thanks
But still I dont get that how to read the lines(string) from an external file " file.txt"
regards

Here's a simple program on how to load the string into the program from a file;

#include <fstream>          // Header File for File Reading
#include <iostream>        // Header File for General I/O-put
#include <string>             // Header File for Strings

using namespace std;        // Use namespacing

char String[1024];          // Create a string as a global var

bool LoadString()           // Function for loading the string
    {
    ifstream in ("String.dat");  // Start Loading data from b.dat
    if (in.good())          // If the file is loadable (existing)
       {
       in >> String;        // Load the string
       return true;
       }
    else                    // If the file is unloadable (nonexisting)
       {
       in.close();          // Stop Loading data form String.dat   
       cout << "Could not load the file!" << endl;    // Post error message
       system("PAUSE");     // Pause, to make the user able to read the error message
       return false;        // Exit the program
       }
    in.close();             // Stop Loading data form String.dat   
    }

int main()
    { 
    if (!LoadString()){return 0;}     // If the function returned 
    cout << "The length of String is " << StringLength() << " characters.\n" << endl;  // Post the length 
    system("PAUSE");        // Pause, to make the user able to read the error message
    return 0;               // Exit the program   
    }

This code is loading the string, from the files dat, and returning the length of it, simply just use the string instead of returning the length.

And an example for two Strings, just made using copypaste:

#include <fstream>          // Header File for File Reading
#include <iostream>         // Header File for General I/O-put
#include <string>           // Header File for Strings

using namespace std;        // Use namespacing

char String[1024];          // Create a string as a global var

bool LoadString()           // Function for loading the string
    {
    ifstream in ("String.dat");  // Start Loading data from b.dat
    if (in.good())          // If the file is loadable (existing)
       {
       in >> String;        // Load the string
       return true;
       }
    else                    // If the file is unloadable (nonexisting)
       {
       in.close();          // Stop Loading data form String.dat   
       cout << "Could not load the file!" << endl;    // Post error message
       system("PAUSE");     // Pause, to make the user able to read the error message
       return false;        // Exit the program
       }
    in.close();             // Stop Loading data form String.dat   
    }

bool LoadString2()           // Function for loading the string
    {
    ifstream in ("String.dat");  // Start Loading data from b.dat
    if (in.good())          // If the file is loadable (existing)
       {
       char Line1[1024];
       in >> Line1 >> String;        // Load the second string
       return true;
       }
    else                    // If the file is unloadable (nonexisting)
       {
       in.close();          // Stop Loading data form String.dat   
       cout << "Could not load the file!" << endl;    // Post error message
       system("PAUSE");     // Pause, to make the user able to read the error message
       return false;        // Exit the program
       }
    in.close();             // Stop Loading data form String.dat   
    }

int StringLength()          // Function for finding the stirng length
    {
    string str (String);    // set str
    return str.length();    // return the length of the string    
    }

int main()
    { 
    if (!LoadString()){return 0;}     // If the function returned 
    cout << "The length of String is " << StringLength() << " characters.\n" << endl;  // Post the length 
    if (!LoadString2()){return 0;}     // If the function returned 
    cout << "The length of String is " << StringLength() << " characters.\n" << endl;  // Post the length 
    system("PAUSE");        // Pause, to make the user able to read the error message
    return 0;               // Exit the program   
    }

Dear Skeen
It helped a lot
Thank you ver much indeed

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.