1
votes

This is the code that I'm trying to execute :

#include <iostream>
#include <dlfcn.h>
#include "wpamethods.h"

using namespace std;

int main()
{

    wpa_methods wm;
    //wm.show_scan_result();

    int choice=1;
    while(choice<3)
    {
        cout<<"Enter your choice : "<<endl<<"1. scan for networks"<<endl<<"2. Show Scan Result"<<endl<<"3. Exit"<<endl;
        //cout<<endl;
        cin>>choice;


        switch(choice)
        {
        case 1:
            cout<<wm.wpa_scan();
            cout<<endl;
            break;
        case 2:
            cout<<endl;
            cout<<wm.show_scan_result();
            break;
        }
    //  sleep(3);
    }

    cout<<endl;
    return 0;
}

All functions of wpa_methods works fine. But I just modified this program to make it menu driven, and here's where I'm stuck.

Everything works except that I have to enter "choice" integer twice for input. Linking of library and header files is working fine. Even if I comment out my statements calling wpa_methods' functions in switch case, I've to give input twice.

Test bed : Eclipse

Platform : Ubuntu 14.04 LTS

Can you please paste code for wpa_methods. Probably that wht causing a problem. The loop seems fine and dummy on my system runs fine also - Spanky
Also, why do you sleep()? No need to do that, input will block regardless. - Andre
Without sleep() also, bug is not getting solved, still I'll remove it. - shreyans800755