Hi guys, am currently creating a client/server program. However im having trouble reading from a text file. Im not sure whether fgets or fread is better in my case. Basically my program requires user to input a country, and the program will display its details out.My question is, what method should i use to store the txt file into a tempdatabase?(or simply use the txt file) and secondly how do I display the required fields only. Is strtoken() the only way?

For example.
Please input country: Czech Republic
Czech Republic capital: Prague
Czech Republic Currency Code: CZK

this is the code im written, however its only the server/client portion as i have no idea how to read the particular file(Countries.txt). Any help is appreciated. Currently running on ubuntu 9.1 on vmware.

server.c

#include <stdlib.h>

#include <stdio.h>

#include <signal.h>

#include <string.h>

#include <sys/types.h>

#include <sys/socket.h>

#include <sys/un.h>       /* for sockaddr_un struct */

#define DEFAULT_PROTOCOL   0



/* POSIX renames "Unix domain" as "local IPC."

    Not all systems define AF_LOCAL and PF_LOCAL (yet). */

#ifndef AF_LOCAL

#define AF_LOCAL    AF_UNIX

#endif

#ifndef PF_LOCAL

#define PF_LOCAL    PF_UNIX

#endif





/****************************************************************/

  main  ()

  {

    int serverFd, clientFd, serverLen, clientLen;

    struct sockaddr_un serverAddress;/* Server address */

    struct sockaddr_un clientAddress; /* Client address */

    struct sockaddr* serverSockAddrPtr; /* Ptr to server address */

    struct sockaddr* clientSockAddrPtr; /* Ptr to client address */



    /* Ignore death-of-child signals to prevent zombies */

    signal (SIGCHLD, SIG_IGN);



    serverSockAddrPtr = (struct sockaddr*) &serverAddress;

    serverLen = sizeof (serverAddress);



    clientSockAddrPtr = (struct sockaddr*) &clientAddress;

    clientLen = sizeof (clientAddress);



    /* Create a socket, bidirectional, default protocol */

    serverFd = socket (AF_LOCAL, SOCK_STREAM, DEFAULT_PROTOCOL);

    serverAddress.sun_family = AF_LOCAL; /* Set domain type */

    strcpy (serverAddress.sun_path, "Countries"); /* Set name */

    unlink ("Countries"); /* Remove file if it already exists */

    bind (serverFd, serverSockAddrPtr, serverLen); /* Create file */

    listen (serverFd, 5); /* Maximum pending connection length */



    while (1) /* Loop forever */

      {

        /* Accept a client connection */

        clientFd = accept (serverFd, clientSockAddrPtr, &clientLen);



        if (fork () == 0) /* Create child to send countries */

          {

            writeCountries (clientFd); /* Send the countries */

            close (clientFd); /* Close the socket */

            exit (/* EXIT_SUCCESS */ 0); /* Terminate */

          }

        else

          close (clientFd); /* Close the client descriptor */

      }

   }



   /****************************************************************/

client.c

#include <stdlib.h>

#include <stdio.h>

#include <signal.h>

#include <string.h>

#include <sys/types.h>

#include <sys/socket.h>

#include <sys/un.h>            /* for sockaddr_un struct*/

#define DEFAULT_PROTOCOL    0



/* POSIX renames "Unix domain" as "local IPC."

    Not all systems define AF_LOCAL and PF_LOCAL (yet). */

#ifndef AF_LOCAL

#define AF_LOCAL    AF_UNIX

#endif

#ifndef PF_LOCAL

#define PF_LOCAL    PF_UNIX

#endif



/****************************************************************/

 main  ()

 {

   int clientFd, serverLen, result;

   struct sockaddr_un serverAddress;

   struct sockaddr* serverSockAddrPtr;

   serverSockAddrPtr = (struct sockaddr*) &serverAddress;

   serverLen = sizeof (serverAddress);



   /* Create a socket, bidirectional, default protocol */

   clientFd = socket (AF_LOCAL, SOCK_STREAM, DEFAULT_PROTOCOL);

   serverAddress.sun_family = AF_LOCAL; /* Server domain */

   strcpy (serverAddress.sun_path, "country"); /* Server name */

   do /* Loop until a connection is made with the server */

     {

       result = connect (clientFd, serverSockAddrPtr, serverLen);

       if (result == -1) sleep (1); /* Wait and then try again */

     }

   while (result == -1);

   readCountry (clientFd); /* Read the country */

   close (clientFd); /* Close the socket */

   exit (/* EXIT_SUCCESS */ 0); /* Done */

 }

 /**************************************************************/



 readCountries (fd)

 int fd;

 {

   char str[200];



   while (readLine (fd, str)) /* Read lines until end-of-input */

     printf ("%s\n", str); /* Echo line from socket */

 }



 /**************************************************************/

Countries.txt

CZ,[b]Czech Republic[/b],EZ,CZ,CZE,203.00,[b]Prague[/b],Europe,[b]Czech Koruna,CZK,[/b]10264212.00
DE,Germany,GM,DE,DEU,276.00,Berlin,Europe,Euro,EUR,83029536.00
DJ,Djibouti,DJ,DJ,DJI,262.00,Djibouti,Africa,Djibouti Franc,DJF,460700.00
DK,Denmark,DA,DK,DNK,208.00,Copenhagen,Europe,Danish Krone,DKK,5352815.00
DM,Dominica,DO,DM,DMA,212.00,Roseau,Central America and the Caribbean,East Caribbean Dollar,XCD,70786.00
DO,Dominican Republic,DR,DO,DOM,214.00,Santo Domingo,Central America and the Caribbean,Dominican Peso,DOP,8581477.00
DZ,Algeria,AG,DZ,DZA,12.00,Algiers,Africa,Algerian Dinar,DZD,31736053.00
EC,Ecuador,EC,EC,ECU,218.00,Quito,South America,US dollar,USD,13183978.00
EE,Estonia,EN,EE,EST,233.00,Tallinn,Europe,Kroon,EEK,1423316.00

The important fields are: Field 2,7,9,10 , which is the fields i want to extract out when user inputs the correct country.

Recommended Answers

All 11 Replies

Right away I can see that your server is not reading the request from the client. So how does your server get the country value or does it send everything with each request?

When the server is run, it will read from countries.txt to store it in a tempdatabase(or not). Server runs/save file into temp. Proceeds to wait for client.
Client establishes connection, waits for user input
Child has database, will search for user input and writes to client for display.

Roughly the gist of the program. Its a bidirectional communication i might add. Thanks again guys

You are right however, this is because i forgot to input one more section of the code(my bad). Just add this section to the server.c. This is however a skeleton of it because i still do not know which methods are better to input txt file into a tempdatabase.

writeRecipe (fd)



   int fd;



   {

     static char* line1 = "testCountry,";

     static char* line2 = "testCapital.";

     write (fd, line1, strlen (line1) + 1); /* Write first line */

     write (fd, line2, strlen (line2) + 1); /* Write second line */

   }

Maybe I'm missing your point.

If I was to write this I would have the client request a country by name from the server. The server in response to the client request would:

1. Read the country's name from the client.
2. Open the file containing the country data(I'll assume its collected in one file)
3. Search file for a country name match.
4. If match is found send the matched line else send a generic error message.

That could work as well. COuld u post a skeleton code for reference?

Adding a little bit more information to gerard4143's post

Open the file (Use fopen for this)
Read the first line of the file and store it in a buffer (Use fread for this)
Go through the line and check if the name of the country appears in the file or not (Use strtok for this)
If a match is found send the contents of the line you just read to the client or send error

im not really good in understanding, perharps posting the skeleton code might help? thanks

hi guys. I finished doing up the database, but i do not know how to incoporate it to the client server model. Any help on this?. Basically i want the server to open Countries.txt, read it and store into a buffer. Client then reads user input, sends it to server. If a match is found send the contents of the line you just read to the client or send error. Appreciate any help on this. Thanks!

My full files are in another thread. I post it again

Main prog

#include "CountryData.h"
void readData ()
{
    FILE * pFile;
    NoOfRecordsRead = 0;
    char buffer [Line_Char_Buffer_Size];

    pFile = fopen (INPUT_FILE_NAME , "r");
   
    if (pFile == NULL) 
         perror ("Error opening file 'Countries.txt' !");
    else
    {
      while ( fgets(buffer, Line_Char_Buffer_Size,pFile) != NULL)
      {
         printf ("%d] aLine => %s\n", NoOfRecordsRead, buffer);
         globalCountryDataArray [NoOfRecordsRead++] = createCountryRecord(buffer);
      }
      fclose (pFile);
    }
			
}
// ====================================================================

CountryRecordType createCountryRecord (char* buffer)
{
	CountryRecordType ctryRec;
	char* pch = strtok (buffer, LINE_DATA_DELIMITER);

	// 1) Retrieve TLD
	strcpy (ctryRec.TLD, pch);
	pch = strtok (NULL, LINE_DATA_DELIMITER);

	// 2) Retrieve Country
	strcpy (ctryRec.Country, pch);
	pch = strtok (NULL, LINE_DATA_DELIMITER);

	// 3) Retrieve FIPS104
	strcpy (ctryRec.FIPS104, pch);
	pch = strtok (NULL, LINE_DATA_DELIMITER);

	// 4) Retrieve ISO2
	strcpy (ctryRec.ISO2, pch);
	pch = strtok (NULL, LINE_DATA_DELIMITER);

	// 5) Retrieve ISO3
	strcpy (ctryRec.ISO3, pch);
	pch = strtok (NULL, LINE_DATA_DELIMITER);

	// 6) Retrieve ISONo
	ctryRec.ISONo = atof (pch);
	pch = strtok (NULL, LINE_DATA_DELIMITER);

	// 7) Retrieve Capital
	strcpy (ctryRec.Capital, pch);
	pch = strtok (NULL, LINE_DATA_DELIMITER);

	// 8) Retrieve Region
	strcpy (ctryRec.Region, pch);
	pch = strtok (NULL, LINE_DATA_DELIMITER);

	// 9) Retrieve Currency
	strcpy (ctryRec.Currency, pch);
	pch = strtok (NULL, LINE_DATA_DELIMITER);

	// 10) Retrieve CurrencyCode
	strcpy (ctryRec.CurrencyCode, pch);
	pch = strtok (NULL, LINE_DATA_DELIMITER);

	// 11) Retrieve Population
	ctryRec.Population = atof (pch);

	return (ctryRec);

}

// ====================================================================

void displayRecordContent (CountryRecordType ctryRec)
{
	printf ("TLD			: %s\n", ctryRec.TLD);
	printf ("Country		: %s\n", ctryRec.Country);
	printf ("FIPS104		: %s\n", ctryRec.FIPS104);
	printf ("ISO2			: %s\n", ctryRec.ISO2);
	printf ("ISO3			: %s\n", ctryRec.ISO3);
	printf ("ISONo			: %lf\n", ctryRec.ISONo);
	printf ("Capital		: %s\n", ctryRec.Capital);
	printf ("Region			: %s\n", ctryRec.Region);
	printf ("Currency		: %s\n", ctryRec.Currency);
	printf ("CurrencyCode	: %s\n", ctryRec.CurrencyCode);
	printf ("Population		: %lf\n\n", ctryRec.Population);
}

// ====================================================================

void showAllRecords ()
{
	int i=0;
	for (i=0; i<NoOfRecordsRead; i++)
	{
		printf ("(%d)\n", i);
		displayRecordContent (globalCountryDataArray [i]);
	}
}

// ====================================================================

int findCountryRecord (const char* countryName)
{
	int idx		= -1;
	int found	= 0;

	while (!found && (++idx < Max_Record_Size))
		if (strcmp (globalCountryDataArray [idx].Country, countryName) == 0)
			found = 1;

	if (found)
		return (idx);
	else
		return (-1);
}

// ====================================================================

char* getCapital (const char* countryName)
{
	int idx = findCountryRecord (countryName);

	if (idx < 0)
	{
		printf ("Country '%s' not found!\n", countryName);
		return (NULL);	
	}
	else
		return (globalCountryDataArray [idx].Capital);
}

// ====================================================================

char* getCurrencyCode (const char* countryName)
{
	int idx = findCountryRecord (countryName);

	if (idx < 0)
	{
		printf ("Country '%s' not found!\n", countryName);
		return (NULL);	
	}
	else
		return (globalCountryDataArray [idx].CurrencyCode);
}



main ()
{
	readData();
//	showAllRecords ();

	char* country1 = "Andorra";

	printf ("%s Capital       : %s\n", country1, getCapital (country1));
	printf ("%s Currency Code : %s\n", country1, getCurrencyCode (country1));


	char* country2 = "Zimbabwe";

	printf ("%s Capital       : %s\n", country2, getCapital (country2));
	printf ("%s Currency Code : %s\n", country2, getCurrencyCode (country2));

	char* country3 = "Malaysia";

	printf ("%s Capital       : %s\n", country3, getCapital (country3));
	printf ("%s Currency Code : %s\n", country3, getCurrencyCode (country3));

}

Library

#ifndef COUNTRY_DATA_H
#define COUNTRY_DATA_H

// ====================================================================

#include <stdlib.h>

#include <stdio.h>

#include <string.h>

// ====================================================================

#define TLD_LEN				2
#define COUNTRY_LEN 		100
#define FIPS104_LEN 		2
#define ISO2_LEN			2
#define ISO3_LEN			3
#define CAPITAL_LEN			100
#define REGION_LEN			100
#define CURRENCY_LEN		50
#define CURRENCY_CODE_LEN	3

#define No_Of_Rec_Fields		11
#define Max_Record_Size			2500
#define Line_Char_Buffer_Size	4000

#define LINE_DATA_DELIMITER 	","
#define INPUT_FILE_NAME 		"Countries.txt"

// ====================================================================

//const char*	LINE_DATA_DELIMITER		= ",";
//const char*	INPUT_FILE_NAME 		= "Countries.txt";


typedef struct CountryRecord
{
	char TLD			[TLD_LEN+1];			// Top Level Domain code
	char Country		[COUNTRY_LEN+1];	
	char FIPS104		[FIPS104_LEN+1];		// Ctry code according to FIPS104 standard
	char ISO2			[ISO2_LEN+1];			// Ctry code according to ISO2    standard
	char ISO3			[ISO3_LEN+1];			// Ctry code according to ISO3    standard
	double ISONo;

	char Capital		[CAPITAL_LEN+1];	
	char Region			[REGION_LEN+1];			// E.g. Asia, Europe, etc.
	char Currency		[CURRENCY_LEN+1];		// Full name of currency
	char CurrencyCode	[CURRENCY_CODE_LEN+1];	// Currency abbreviation
	double Population;

}	CountryRecordType;


int NoOfRecordsRead;
CountryRecordType globalCountryDataArray [Max_Record_Size];

// ====================================================================

void readData ();
char* get_line (char *s, size_t n, FILE *f);
CountryRecordType createCountryRecord (char* aLine);
void displayRecordContent (CountryRecordType ctryRec);
void showAllRecords ();

int findCountryRecord (const char* countryName);
char* getCapital (const char* countryName);
char* getCurrencyCode (const char* countryName);

// ====================================================================

#endif // COUNTRY_DATA_H

Countries.txt

AD,Andorra,AN,AD,AND,20.00,Andorra la Vella,Europe,Euro,EUR,67627.00
AE,United Arab Emirates,AE,AE,ARE,784.00,Abu Dhabi,Middle East,UAE Dirham,AED,2407460.00
AF,Afghanistan,AF,AF,AFG,4.00,Kabul,Asia,Afghani,AFA,26813057.00
AG,Antigua and Barbuda,AC,AG,ATG,28.00,Saint John's,Central America and the Caribbean,East Caribbean Dollar,XCD,66970.00
AI,Anguilla,AV,AI,AIA,660.00,The Valley,Central America and the Caribbean,East Caribbean Dollar,XCD,12132.00
AL,Albania,AL,AL,ALB,8.00,Tirana,Europe,Lek,ALL,3510484.00
AM,Armenia,AM,AM,ARM,51.00,Yerevan,Commonwealth of Independent States,Armenian Dram,AMD,3336100.00
AN,Netherlands Antilles,NT,AN,ANT,530.00,Willemstad,Central America and the Caribbean,Netherlands Antillean guilder,ANG,212226.00
AO,Angola,AO,AO,AGO,24.00,Luanda,Africa,Kwanza,AOA,10366031.00
AQ,Antarctica,AY,AQ,ATA,10.00,--,Antarctic Region, , ,0.00
AR,Argentina,AR,AR,ARG,32.00,Buenos Aires,South America,Argentine Peso,ARS,37384816.00
AS,American Samoa,AQ,AS,ASM,16.00,Pago Pago,Oceania,US Dollar,USD,67084.00
AT,Austria,AU,AT,AUT,40.00,Vienna,Europe,Euro,EUR,8150835.00
AU,Australia,AS,AU,AUS,36.00,Canberra,Oceania,Australian dollar,AUD,19357594.00
AW,Aruba,AA,AW,ABW,533.00,Oranjestad,Central America and the Caribbean,Aruban Guilder,AWG,70007.00
AZ,Azerbaijan,AJ,AZ,AZE,31.00,Baku (Baki),Commonwealth of Independent States,Azerbaijani Manat,AZM,7771092.00
BA,Bosnia and Herzegovina,BK,BA,BIH,70.00,Sarajevo,Bosnia and Herzegovina (Europe),Convertible Marka,BAM,3922205.00
BB,Barbados,BB,BB,BRB,52.00,Bridgetown,Central America and the Caribbean,Barbados Dollar,BBD,275330.00
BD,Bangladesh,BG,BD,BGD,50.00,Dhaka,Asia,Taka,BDT,131269860.00
BE,Belgium,BE,BE,BEL,56.00,Brussels,Europe,Euro,EUR,10258762.00
BF,Burkina Faso,UV,BF,BFA,854.00,Ouagadougou,Africa,CFA Franc BCEAO,XOF,12272289.00
BG,Bulgaria,BU,BG,BGR,100.00,Sofia,Europe,Lev,BGL,7707495.00
BH,Bahrain,BA,BH,BHR,48.00,Manama,Middle East,Bahraini Dinar,BHD,645361.00
BI,Burundi,BY,BI,BDI,108.00,Bujumbura,Africa,Burundi Franc,BIF,6223897.00
BJ,Benin,BN,BJ,BEN,204.00,Porto-Novo ,Africa,CFA Franc BCEAO,XOF,6590782.00
BM,Bermuda,BD,BM,BMU,60.00,Hamilton,North America,Bermudian Dollar,BMD,63503.00
BN,Brunei Darussalam,BX,BN,BRN,96.00,Bandar Seri Begawan,Southeast Asia,Brunei Dollar,BND,
BO,Bolivia,BL,BO,BOL,68.00,La Paz /Sucre,South America,Boliviano,BOB,8300463.00
BR,Brazil,BR,BR,BRA,76.00,Brasilia,South America,Brazilian Real,BRL,174468575.00
BS,The Bahamas,BF,BS,BHS,44.00,Nassau,Central America and the Caribbean,Bahamian Dollar,BSD,297852.00
BT,Bhutan,BT,BT,BTN,64.00,Thimphu,Asia,Ngultrum,BTN,2049412.00
BV,Bouvet Island,BV,BV,BVT,74.00,--,Antarctic Region,Norwegian Krone,NOK,0.00
BW,Botswana,BC,BW,BWA,72.00,Gaborone,Africa,Pula,BWP,1586119.00
BY,Belarus,BO,BY,BLR,112.00,Minsk,Commonwealth of Independent States,Belarussian Ruble,BYR,10350194.00
BZ,Belize,BH,BZ,BLZ,84.00,Belmopan,Central America and the Caribbean,Belize Dollar,BZD,256062.00
CA,Canada,CA,CA,CAN,124.00,Ottawa,North America,Canadian Dollar,CAD,31592805.00
CC,Cocos (Keeling) Islands,CK,CC,CCK,166.00,West Island,Southeast Asia,Australian Dollar,AUD,633.00
CD,Congo, Democratic Republic of the,CG,CD,COD,180.00,Kinshasa,Africa,Franc Congolais,CDF,53624718.00
CF,Central African Republic,CT,CF,CAF,140.00,Bangui,Africa,CFA Franc BEAC,XAF,3576884.00
CG,Congo, Republic of the,CF,CG,COG,178.00,Brazzaville,Africa,CFA Franc BEAC,XAF,2894336.00
CH,Switzerland,SZ,CH,CHE,756.00,Bern,Europe,Swiss Franc,CHF,7283274.00
CI,Cote d'Ivoire,IV,CI,CIV,384.00,Yamoussoukro,Africa,CFA Franc BCEAO,XOF,16393221.00
CK,Cook Islands,CW,CK,COK,184.00,Avarua,Oceania,New Zealand Dollar,NZD,20611.00
CL,Chile,CI,CL,CHL,152.00,Santiago,South America,Chilean Peso,CLP,15328467.00
CM,Cameroon,CM,CM,CMR,120.00,Yaounde,Africa,CFA Franc BEAC,XAF,15803220.00
CN,China,CH,CN,CHN,156.00,Beijing,Asia,Yuan Renminbi,CNY,1273111290.00
CO,Colombia,CO,CO,COL,170.00,Bogota,South America, Central America and the Caribbean,Colombian Peso,COP,40349388.00
CR,Costa Rica,CS,CR,CRI,188.00,San Jose,Central America and the Caribbean,Costa Rican Colon,CRC,3773057.00
CU,Cuba,CU,CU,CUB,192.00,Havana,Central America and the Caribbean,Cuban Peso,CUP,11184023.00
CV,Cape Verde,CV,CV,CPV,132.00,Praia,World,Cape Verdean Escudo,CVE,405163.00
CX,Christmas Island,KT,CX,CXR,162.00,The Settlement,Southeast Asia,Australian Dollar,AUD,2771.00
CY,Cyprus,CY,CY,CYP,196.00,Nicosia,Middle East,Cyprus Pound,CYP,762887.00
CZ,Czech Republic,EZ,CZ,CZE,203.00,Prague,Europe,Czech Koruna,CZK,10264212.00
DE,Germany,GM,DE,DEU,276.00,Berlin,Europe,Euro,EUR,83029536.00
DJ,Djibouti,DJ,DJ,DJI,262.00,Djibouti,Africa,Djibouti Franc,DJF,460700.00
DK,Denmark,DA,DK,DNK,208.00,Copenhagen,Europe,Danish Krone,DKK,5352815.00
DM,Dominica,DO,DM,DMA,212.00,Roseau,Central America and the Caribbean,East Caribbean Dollar,XCD,70786.00
DO,Dominican Republic,DR,DO,DOM,214.00,Santo Domingo,Central America and the Caribbean,Dominican Peso,DOP,8581477.00
DZ,Algeria,AG,DZ,DZA,12.00,Algiers,Africa,Algerian Dinar,DZD,31736053.00
EC,Ecuador,EC,EC,ECU,218.00,Quito,South America,US dollar,USD,13183978.00
EE,Estonia,EN,EE,EST,233.00,Tallinn,Europe,Kroon,EEK,1423316.00
EG,Egypt,EG,EG,EGY,818.00,Cairo,Africa,Egyptian Pound,EGP,69536644.00
EH,Western Sahara,WI,EH,ESH,732.00,--,Africa,Moroccan Dirham,MAD,250559.00
ER,Eritrea,ER,ER,ERI,232.00,Asmara,Africa,Nakfa,ERN,4298269.00
ES,Spain,SP,ES,ESP,724.00,Madrid,Europe,Euro,EUR,40037995.00
ET,Ethiopia,ET,ET,ETH,231.00,Addis Ababa,Africa,Ethiopian Birr,ETB,65891874.00
FI,Finland,FI,FI,FIN,246.00,Helsinki,Europe,Euro,EUR,5175783.00
FJ,Fiji,FJ,FJ,FJI,242.00,Suva,Oceania,Fijian Dollar,FJD,844330.00
FK,Falkland Islands (Islas Malvinas),FK,FK,FLK,238.00,Stanley,South America,Falkland Islands Pound,FKP,2895.00
FM,Micronesia, Federated States of,FM,FM,FSM,583.00,Palikir,Oceania,US dollar,USD,134597.00
FO,Faroe Islands,FO,FO,FRO,234.00,Torshavn,Europe,Danish Krone,DKK,45661.00
FR,France,FR,FR,FRA,250.00,Paris,Europe,Euro,EUR,59551227.00
FX,France, Metropolitan,--,--,--,-1.00,--, ,Euro,EUR,
GA,Gabon,GB,GA,GAB,266.00,Libreville,Africa,CFA Franc BEAC,XAF,1221175.00
GD,Grenada,GJ,GD,GRD,308.00,Saint George's,Central America and the Caribbean,East Caribbean Dollar,XCD,89227.00
GE,Georgia,GG,GE,GEO,268.00,T'bilisi,Commonwealth of Independent States,Lari,GEL,4989285.00
GF,French Guiana,FG,GF,GUF,254.00,Cayenne,South America,Euro,EUR,177562.00
GG,Guernsey,GK,--,--,-1.00,Saint Peter Port,Europe,Pound Sterling,GBP,64342.00
GH,Ghana,GH,GH,GHA,288.00,Accra,Africa,Cedi,GHC,19894014.00
GI,Gibraltar,GI,GI,GIB,292.00,Gibraltar,Europe,Gibraltar Pound,GIP,27649.00
GL,Greenland,GL,GL,GRL,304.00,Nuuk,Arctic Region,Danish Krone,DKK,56352.00
GM,The Gambia,GA,GM,GMB,270.00,Banjul,Africa,Dalasi,GMD,1411205.00
GN,Guinea,GV,GN,GIN,324.00,Conakry,Africa,Guinean Franc,GNF,7613870.00
GP,Guadeloupe,GP,GP,GLP,312.00,Basse-Terre,Central America and the Caribbean,Euro,EUR,431170.00
GQ,Equatorial Guinea,EK,GQ,GNQ,226.00,Malabo,Africa,CFA Franc BEAC,XAF,486060.00
GR,Greece,GR,GR,GRC,300.00,Athens,Europe,Euro,EUR,10623835.00
GS,South Georgia and the South Sandwich Islands,SX,GS,SGS,239.00,--,Antarctic Region,Pound Sterling,GBP,0.00
GT,Guatemala,GT,GT,GTM,320.00,Guatemala,Central America and the Caribbean,Quetzal,GTQ,12974361.00
GU,Guam,GQ,GU,GUM,316.00,Hagatna,Oceania,US Dollar,USD,157557.00
GW,Guinea-Bissau,PU,GW,GNB,624.00,Bissau,Africa,CFA Franc BCEAO,XOF,1315822.00
GY,Guyana,GY,GY,GUY,328.00,Georgetown,South America,Guyana Dollar,GYD,697181.00
HK,Hong Kong (SAR),HK,HK,HKG,344.00,Hong Kong,Southeast Asia,Hong Kong Dollar,HKD,0.00
HM,Heard Island and McDonald Islands,HM,HM,HMD,334.00,--,Antarctic Region,Australian Dollar,AUD,0.00
HN,Honduras,HO,HN,HND,340.00,Tegucigalpa,Central America and the Caribbean,Lempira,HNL,6406052.00
HR,Croatia,HR,HR,HRV,191.00,Zagreb,Europe,Kuna,HRK,4334142.00
HT,Haiti,HA,HT,HTI,332.00,Port-au-Prince,Central America and the Caribbean,Gourde,HTG,6964549.00
HU,Hungary,HU,HU,HUN,348.00,Budapest,Europe,Forint,HUF,10106017.00
ID,Indonesia,ID,ID,IDN,360.00,Jakarta,Southeast Asia,Rupiah,IDR,228437870.00
IE,Ireland,EI,IE,IRL,372.00,Dublin,Europe,Euro,EUR,3840838.00
IL,Israel,IS,IL,ISR,376.00,Jerusalem,Middle East,New Israeli Sheqel,ILS,5938093.00
IM,Man, Isle of,IM,--,--,-1.00,Douglas,Europe,Pound Sterling,GBP,73489.00
IN,India,IN,IN,IND,356.00,New Delhi,Asia,Indian Rupee,INR,1029991145.00
IO,British Indian Ocean Territory,IO,IO,IOT,86.00,--,World,US Dollar,USD,0.00
IQ,Iraq,IZ,IQ,IRQ,368.00,Baghdad,Middle East,Iraqi Dinar,IQD,23331985.00
IR,Iran,IR,IR,IRN,364.00,Tehran,Middle East,Iranian Rial,IRR,66128965.00
IS,Iceland,IC,IS,ISL,352.00,Reykjavik,Arctic Region,Iceland Krona,ISK,277906.00
IT,Italy,IT,IT,ITA,380.00,Rome,Europe,Euro,EUR,57679825.00
JE,Jersey,JE,--,--,-1.00,Saint Helier,Europe,Pound Sterling,GBP,89361.00
JM,Jamaica,JM,JM,JAM,388.00,Kingston,Central America and the Caribbean,Jamaican dollar,JMD,2665636.00
JO,Jordan,JO,JO,JOR,400.00,Amman,Middle East,Jordanian Dinar,JOD,5153378.00
JP,Japan,JA,JP,JPN,392.00,Tokyo,Asia,Yen,JPY,126771662.00
KE,Kenya,KE,KE,KEN,404.00,Nairobi,Africa,Kenyan shilling,KES,30765916.00
KG,Kyrgyzstan,KG,KG,KGZ,417.00,Bishkek,Commonwealth of Independent States,Som,KGS,4753003.00
KH,Cambodia,CB,KH,KHM,116.00,Phnom Penh,Southeast Asia,Riel,KHR,12491501.00
KI,Kiribati,KR,KI,KIR,296.00,Tarawa,Oceania,Australian dollar,AUD,94149.00
KM,Comoros,CN,KM,COM,174.00,Moroni,Africa,Comoro Franc,KMF,596202.00
KN,Saint Kitts and Nevis,SC,KN,KNA,659.00,Basseterre,Central America and the Caribbean,East Caribbean Dollar,XCD,38756.00
KP,Korea,KN,KP,PRK,408.00,Pyongyang,Asia,North Korean Won,KPW,21968228.00
KR,Korea,KS,KR,KOR,410.00,Seoul,Asia,Won,KRW,47904370.00
KW,Kuwait,KU,KW,KWT,414.00,Kuwait,Middle East,Kuwaiti Dinar,KWD,2041961.00
KY,Cayman Islands,CJ,KY,CYM,136.00,George Town,Central America and the Caribbean,Cayman Islands Dollar,KYD,35527.00
KZ,Kazakhstan,KZ,KZ,KAZ,398.00,Astana,Commonwealth of Independent States,Tenge,KZT,16731303.00
LA,Laos,LA,LA,LAO,418.00,Vientiane,Southeast Asia,Kip,LAK,5635967.00
LB,Lebanon,LE,LB,LBN,422.00,Beirut,Middle East,Lebanese Pound,LBP,3627774.00
LC,Saint Lucia,ST,LC,LCA,662.00,Castries,Central America and the Caribbean,East Caribbean Dollar,XCD,158178.00
LI,Liechtenstein,LS,LI,LIE,438.00,Vaduz,Europe,Swiss Franc,CHF,32528.00
LK,Sri Lanka,CE,LK,LKA,144.00,Colombo,Asia,Sri Lanka Rupee,LKR,19408635.00
LR,Liberia,LI,LR,LBR,430.00,Monrovia,Africa,Liberian Dollar,LRD,3225837.00
LS,Lesotho,LT,LS,LSO,426.00,Maseru,Africa,Loti,LSL,2177062.00
LT,Lithuania,LH,LT,LTU,440.00,Vilnius,Europe,Lithuanian Litas,LTL,3610535.00
LU,Luxembourg,LU,LU,LUX,442.00,Luxembourg,Europe,Euro,EUR,442972.00
LV,Latvia,LG,LV,LVA,428.00,Riga,Europe,Latvian Lats,LVL,2385231.00
LY,Libya,LY,LY,LBY,434.00,Tripoli,Africa,Libyan Dinar,LYD,5240599.00
MA,Morocco,MO,MA,MAR,504.00,Rabat,Africa,Moroccan Dirham,MAD,30645305.00
MC,Monaco,MN,MC,MCO,492.00,Monaco,Europe,Euro,EUR,31842.00
MD,Moldova,MD,MD,MDA,498.00,Chisinau,Commonwealth of Independent States,Moldovan Leu,MDL,4431570.00
MG,Madagascar,MA,MG,MDG,450.00,Antananarivo,Africa,Malagasy Franc,MGF,15982563.00
MH,Marshall Islands,RM,MH,MHL,584.00,Majuro,Oceania,US dollar,USD,70822.00
MK,Macedonia, The Former Yugoslav Republic of,MK,MK,MKD,807.00,Skopje,Europe,Denar,MKD,2046209.00
ML,Mali,ML,ML,MLI,466.00,Bamako,Africa,CFA Franc BCEAO,XOF,11008518.00
MM,Burma,BM,MM,MMR,104.00,Rangoon,Southeast Asia,kyat,MMK,41994678.00
MN,Mongolia,MG,MN,MNG,496.00,Ulaanbaatar,Asia,Tugrik,MNT,2654999.00
MO,Macao,MC,MO,MAC,446.00,Macao,Southeast Asia,Pataca,MOP,453733.00
MP,Northern Mariana Islands,CQ,MP,MNP,580.00,Saipan,Oceania,US Dollar,USD,74612.00
MQ,Martinique,MB,MQ,MTQ,474.00,Fort-de-France,Central America and the Caribbean,Euro,EUR,418454.00
MR,Mauritania,MR,MR,MRT,478.00,Nouakchott,Africa,Ouguiya,MRO,2747312.00
MS,Montserrat,MH,MS,MSR,500.00,Plymouth,Central America and the Caribbean,East Caribbean Dollar,XCD,7574.00
MT,Malta,MT,MT,MLT,470.00,Valletta,Europe,Maltese Lira,MTL,394583.00
MU,Mauritius,MP,MU,MUS,480.00,Port Louis,World,Mauritius Rupee,MUR,1189825.00
MV,Maldives,MV,MV,MDV,462.00,Male,Asia,Rufiyaa,MVR,310764.00
MW,Malawi,MI,MW,MWI,454.00,Lilongwe,Africa,Kwacha,MWK,10548250.00
MX,Mexico,MX,MX,MEX,484.00,Mexico,North America,Mexican Peso,MXN,101879171.00
MY,Malaysia,MY,MY,MYS,458.00,Kuala Lumpur,Southeast Asia,Malaysian Ringgit,MYR,22229040.00
MZ,Mozambique,MZ,MZ,MOZ,508.00,Maputo,Africa,Metical,MZM,19371057.00
NA,Namibia,WA,NA,NAM,516.00,Windhoek,Africa,Namibian Dollar,NAD,1797677.00
NC,New Caledonia,NC,NC,NCL,540.00,Noumea,Oceania,CFP Franc,XPF,204863.00
NE,Niger,NG,NE,NER,562.00,Niamey,Africa,CFA Franc BCEAO,XOF,10355156.00
NF,Norfolk Island,NF,NF,NFK,574.00,Kingston,Oceania,Australian Dollar,AUD,1879.00
NG,Nigeria,NI,NG,NGA,566.00,Abuja,Africa,Naira,NGN,126635626.00
NI,Nicaragua,NU,NI,NIC,558.00,Managua,Central America and the Caribbean,Cordoba Oro,NIO,4918393.00
NL,Netherlands,NL,NL,NLD,528.00,Amsterdam,Europe,Euro,EUR,15981472.00
NO,Norway,NO,NO,NOR,578.00,Oslo,Europe,Norwegian Krone,NOK,4503440.00
NP,Nepal,NP,NP,NPL,524.00,Kathmandu,Asia,Nepalese Rupee,NPR,25284463.00
NR,Nauru,NR,NR,NRU,520.00,--,Oceania,Australian Dollar,AUD,12088.00
NU,Niue,NE,NU,NIU,570.00,Alofi,Oceania,New Zealand Dollar,NZD,2124.00
NZ,New Zealand,NZ,NZ,NZL,554.00,Wellington,Oceania,New Zealand Dollar,NZD,3864129.00
OM,Oman,MU,OM,OMN,512.00,Muscat,Middle East,Rial Omani,OMR,2622198.00
PA,Panama,PM,PA,PAN,591.00,Panama,Central America and the Caribbean,balboa,PAB,2845647.00
PE,Peru,PE,PE,PER,604.00,Lima,South America,Nuevo Sol,PEN,27483864.00
PF,French Polynesia,FP,PF,PYF,258.00,Papeete,Oceania,CFP Franc,XPF,253506.00
PG,Papua New Guinea,PP,PG,PNG,598.00,Port Moresby,Oceania,Kina,PGK,5049055.00
PH,Philippines,RP,PH,PHL,608.00,Manila,Southeast Asia,Philippine Peso,PHP,82841518.00
PK,Pakistan,PK,PK,PAK,586.00,Islamabad,Asia,Pakistan Rupee,PKR,144616639.00
PL,Poland,PL,PL,POL,616.00,Warsaw,Europe,Zloty,PLN,38633912.00
PM,Saint Pierre and Miquelon,SB,PM,SPM,666.00,Saint-Pierre,North America,Euro,EUR,6928.00
PN,Pitcairn Islands,PC,PN,PCN,612.00,Adamstown,Oceania,New Zealand Dollar,NZD,47.00
PR,Puerto Rico,RQ,PR,PRI,630.00,San Juan,Central America and the Caribbean,US dollar,USD,3937316.00
PS,Palestinian Territory, Occupied,--,PS,PSE,275.00,--, ,, ,
PT,Portugal,PO,PT,PRT,620.00,Lisbon,Europe,Euro,EUR,10066253.00
PW,Palau,PS,PW,PLW,585.00,Koror,Oceania,US dollar,USD,19092.00
PY,Paraguay,PA,PY,PRY,600.00,Asuncion,South America,Guarani,PYG,5734139.00
QA,Qatar,QA,QA,QAT,634.00,Doha,Middle East,Qatari Rial,QAR,769152.00
RO,Romania,RO,RO,ROU,642.00,Bucharest,Europe,Leu,ROL,22364022.00
RU,Russia,RS,RU,RUS,643.00,Moscow,Asia,Russian Ruble,RUB,145470197.00
RW,Rwanda,RW,RW,RWA,646.00,Kigali,Africa,Rwanda Franc,RWF,7312756.00
SA,Saudi Arabia,SA,SA,SAU,682.00,Riyadh,Middle East,Saudi Riyal,SAR,22757092.00
SB,Solomon Islands,BP,SB,SLB,90.00,Honiara,Oceania,Solomon Islands Dollar,SBD,480442.00
SC,Seychelles,SE,SC,SYC,690.00,Victoria,Africa,Seychelles Rupee,SCR,79715.00
SD,Sudan,SU,SD,SDN,736.00,Khartoum,Africa,Sudanese Dinar,SDD,36080373.00
SE,Sweden,SW,SE,SWE,752.00,Stockholm,Europe,Swedish Krona,SEK,8875053.00
SG,Singapore,SN,SG,SGP,702.00,Singapore,Southeast Asia,Singapore Dollar,SGD,4300419.00
SH,Saint Helena,SH,SH,SHN,654.00,Jamestown,Africa,Saint Helenian Pound,SHP,7266.00
SI,Slovenia,SI,SI,SVN,705.00,Ljubljana,Europe,Tolar,SIT,1930132.00
SJ,Svalbard,SV,SJ,SJM,744.00,Longyearbyen,Arctic Region,Norwegian Krone,NOK,2332.00
SK,Slovakia,LO,SK,SVK,703.00,Bratislava,Europe,Slovak Koruna,SKK,5414937.00
SL,Sierra Leone,SL,SL,SLE,694.00,Freetown,Africa,Leone,SLL,5426618.00
SM,San Marino,SM,SM,SMR,674.00,San Marino,Europe,Euro,EUR,27336.00
SN,Senegal,SG,SN,SEN,686.00,Dakar,Africa,CFA Franc BCEAO,XOF,10284929.00
SO,Somalia,SO,SO,SOM,706.00,Mogadishu,Africa,Somali Shilling,SOS,7488773.00
SR,Suriname,NS,SR,SUR,740.00,Paramaribo,South America,Suriname Guilder,SRG,433998.00
SV,El Salvador,ES,SV,SLV,222.00,San Salvador,Central America and the Caribbean,El Salvador Colon,SVC,6237662.00
SY,Syria,SY,SY,SYR,760.00,Damascus,Middle East,Syrian Pound,SYP,16728808.00
SZ,Swaziland,WZ,SZ,SWZ,748.00,Mbabane,Africa,Lilangeni,SZL,1104343.00
TC,Turks and Caicos Islands,TK,TC,TCA,796.00,Cockburn Town,Central America and the Caribbean,US Dollar,USD,18122.00
TD,Chad,CD,TD,TCD,148.00,N'Djamena,Africa,CFA Franc BEAC,XAF,8707078.00
TF,French Southern and Antarctic Lands,FS,TF,ATF,260.00,--,Antarctic Region,Euro,EUR,0.00
TG,Togo,TO,TG,TGO,768.00,Lome,Africa,CFA Franc BCEAO,XOF,5153088.00
TH,Thailand,TH,TH,THA,764.00,Bangkok,Southeast Asia,Baht,THB,61797751.00
TJ,Tajikistan,TI,TJ,TJK,762.00,Dushanbe,Commonwealth of Independent States,Somoni,TJS,6578681.00
TK,Tokelau,TL,TK,TKL,772.00,--,Oceania,New Zealand Dollar,NZD,1445.00
TM,Turkmenistan,TX,TM,TKM,795.00,Ashgabat,Commonwealth of Independent States,Manat,TMM,4603244.00
TN,Tunisia,TS,TN,TUN,788.00,Tunis,Africa,Tunisian Dinar,TND,9705102.00
TO,Tonga,TN,TO,TON,776.00,Nuku'alofa,Oceania,Pa'anga,TOP,104227.00
TP,East Timor,TT,TL,TLS,626.00,--, ,Timor Escudo,TPE,
TR,Turkey,TU,TR,TUR,792.00,Ankara,Middle East,Turkish Lira,TRL,66493970.00
TT,Trinidad and Tobago,TD,TT,TTO,780.00,Port-of-Spain,Central America and the Caribbean,Trinidad and Tobago Dollar,TTD,1169682.00
TV,Tuvalu,TV,TV,TUV,798.00,Funafuti,Oceania,Australian Dollar,AUD,10991.00
TW,Taiwan,TW,TW,TWN,158.00,Taipei,Southeast Asia,New Taiwan Dollar,TWD,22370461.00
TZ,Tanzania,TZ,TZ,TZA,834.00,Dar es Salaam,Africa,Tanzanian Shilling,TZS,36232074.00
UA,Ukraine,UP,UA,UKR,804.00,Kiev,Commonwealth of Independent States,Hryvnia,UAH,48760474.00
UG,Uganda,UG,UG,UGA,800.00,Kampala,Africa,Uganda Shilling,UGX,23985712.00
UK,United Kingdom,UK,GB,GBR,826.00,London,Europe,Pound Sterling,GBP,59647790.00
UM,United States Minor Outlying Islands,--,UM,UMI,581.00,--, ,US Dollar,USD,0.00
US,United States,US,US,USA,840.00,Washington, DC,North America,US Dollar,USD,278058881.00
UY,Uruguay,UY,UY,URY,858.00,Montevideo,South America,Peso Uruguayo,UYU,3360105.00
UZ,Uzbekistan,UZ,UZ,UZB,860.00,Tashkent,Commonwealth of Independent States,Uzbekistan Sum,UZS,25155064.00
VA,Holy See (Vatican City),VT,VA,VAT,336.00,Vatican City,Europe,Euro,EUR,890.00
VC,Saint Vincent and the Grenadines,VC,VC,VCT,670.00,Kingstown,Central America and the Caribbean,East Caribbean Dollar,XCD,115942.00
VE,Venezuela,VE,VE,VEN,862.00,Caracas,South America, Central America and the Caribbean,Bolivar,VEB,23916810.00
VG,British Virgin Islands,VI,VG,VGB,92.00,Road Town,Central America and the Caribbean,US Dollar,USD,20812.00
VI,Virgin Islands,VQ,VI,VIR,850.00,Charlotte Amalie,Central America and the Caribbean,US Dollar,USD,122211.00
VN,Vietnam,VM,VN,VNM,704.00,Hanoi,Southeast Asia,Dong,VND,79939014.00
VU,Vanuatu,NH,VU,VUT,548.00,Port-Vila,Oceania,Vatu,VUV,192910.00
WF,Wallis and Futuna,WF,WF,WLF,876.00,Mata-Utu,Oceania,CFP Franc,XPF,15435.00
WS,Samoa,WS,WS,WSM,882.00,Apia,Oceania,Tala,WST,179058.00
YE,Yemen,YM,YE,YEM,887.00,Sanaa,Middle East,Yemeni Rial,YER,18078035.00
YT,Mayotte,MF,YT,MYT,175.00,Mamoutzou,Africa,Euro,EUR,163366.00
YU,Yugoslavia,YI,YU,YUG,891.00,Belgrade,Europe,Yugoslavian Dinar,YUM,10677290.00
ZA,South Africa,SF,ZA,ZAF,710.00,Pretoria,Africa,Rand,ZAR,43586097.00
ZM,Zambia,ZA,ZM,ZWB,894.00,Lusaka,Africa,Kwacha,ZMK,9770199.00
ZW,Zimbabwe,ZI,ZW,ZWE,716.00,Harare,Africa,Zimbabwe Dollar,ZWD,11365366.00

Guys this is urgent, appreciate prompt replies. Thanks very much

im not really good in understanding, perharps posting the skeleton code might help? thanks

I have written the names of the functions that you need to use. If you search for each function you will get a ton of information.

Hi abhimanipal. I have already incoporated some of the functions you mentioned in my database found above. I only lack the knowledge of inputting it in a client server model. Maybe you can post some psuedocodes to help. That would really help me out alot

Once again thanks for all your replies and help. Much appreciated

Hi, I written some of the functions u mentioned into a database i wrote. Now i only lack the knowledge to how to insert into client server model. Best if you can provide a psuedocode. Thanks for your help

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.