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..:?:
******************************************************************
OUTPUT:
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..
#include<iostream>
#include<string>
#include<stdio.h>
#include<string.h>
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";
//else
{
while(fgets(whole,800,f)!=0)
{
int a=0, i;
char delimeter[]="-\"", who[100][100];
char *huj=strtok(whole, delimeter);
while(huj!=NULL)
{
if(a++>=sizeof who/ sizeof *who)
{
break;
}
huj=strtok(NULL, delimeter);
}
for (i=0; i<a; i++)
{
strncpy(who[i],huj,300);
if(strcmp(code,who[0])!=0)
{
cout << who[1]<<endl;
exit(1);
}
else
{ cout << "INVALID!!!";
exit(1);
}
}
}
fclose(f);
}
return 0;
}
:rolleyes: