Ahmmm .. I'm a newbie in C++ programming, and my BOSS wants me to do a program that accepts a COUNTRY CODE and its output must be the COUNTRY NAME of that COUNTRY CODE and following on the COUNTRY NAME is there Biggest TELEPHONE OPERATOR..:?:


Please Enter Country Code: US (e.g.)

United States: Digicel, US Mobil etc...

I have a database save in countrycode.csv that has the all list of the country code with their country names and their telephone operators,,,
My problem is the output is always segmentation fault..
MR.DANI or guys/ladies(proffesionals) please give me some ideas how to solve it... thanks :confused::rolleyes::sad::-|
My examined main source program is something like this..


using namespace std;
int main()
char code[10];
char whole[800];

cout << "\n\n\tType the Country Code: \t\t ";
cin >> code;
    FILE *f;    
    f=fopen("countrycode.csv", "r");
            //if(f==NULL) cout<< "cant open";
        int a=0, i;
        char delimeter[]="-\"", who[100][100];

        char *huj=strtok(whole, delimeter);
        if(a++>=sizeof who/ sizeof *who)
            huj=strtok(NULL, delimeter);

    for (i=0; i<a; i++)
        cout << who[1]<<endl;
    {    cout << "INVALID!!!";
return 0;



As for your code, why in the world are you mixing C and C++? If you're going to use C++, make sure you use ifstream for your file input.

>> strncpy(who,huj,300);
This line is probably causing the problem. each element of who can only contain 100 characters and that line is copying up to 300 characters into it. Won't fit.