I am having a problem either initializing this array or getting to its contents.
What is wrong here?/*Body of program*/
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
/*Function Library*/
/* global variables */
int main(void)
{
/* Start Program */
float amount, USDollarFromAmount, USDollars; /* variable name */
int success = 0;
int status, i, x, num, selection;
/* Currency rates as of 1/19/04 */
struct Currency_rec
{
char cname[15];
float camount;
};
struct Currency_rec country[5] =
{
{"Euro", 0.81},
{"Swiss Franc", 1.27 },
{"Mexican Peso", 10.80 },
{"British Pound", 0.56 },
{"Japanese Yen", 107.00 }
};
/* Printing Title - I added an extra line break */
/*cls*/;
printf("\nForeign Currency Conversion Program\n"
printf("===================================\n\n "
/*Assigning constants to variable names*/
/* Display Header */
printf("Selection: Currency:\n"
printf("----------------------\n"
for (i = 0; i < 5; ++i)
{
/* num is one more that rthe offset to display option numbers */
num = i + 1;
/*Display the option number and the country name */
fflush(stdin);
printf("%d. %s\n",num , country.cname);
}
num++;
printf("%d. Exit",num);
/* Print Termination message */
printf ("\nProgram terminated!"
getchar();
return 0;
}
The output is as follows:
C:\WINDOWS\HIMEM.SYS
Foreign Currency Conversion Program
===================================
Selection: Currency:
----------------------
1. ÖÖÖÖÖ%@8
2.
3.
4.
5.
6. Exit
Program terminated!
what am I doing wrong?
What is wrong here?/*Body of program*/
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
/*Function Library*/
/* global variables */
int main(void)
{
/* Start Program */
float amount, USDollarFromAmount, USDollars; /* variable name */
int success = 0;
int status, i, x, num, selection;
/* Currency rates as of 1/19/04 */
struct Currency_rec
{
char cname[15];
float camount;
};
struct Currency_rec country[5] =
{
{"Euro", 0.81},
{"Swiss Franc", 1.27 },
{"Mexican Peso", 10.80 },
{"British Pound", 0.56 },
{"Japanese Yen", 107.00 }
};
/* Printing Title - I added an extra line break */
/*cls*/;
printf("\nForeign Currency Conversion Program\n"
printf("===================================\n\n "
/*Assigning constants to variable names*/
/* Display Header */
printf("Selection: Currency:\n"
printf("----------------------\n"
for (i = 0; i < 5; ++i)
{
/* num is one more that rthe offset to display option numbers */
num = i + 1;
/*Display the option number and the country name */
fflush(stdin);
printf("%d. %s\n",num , country.cname);
}
num++;
printf("%d. Exit",num);
/* Print Termination message */
printf ("\nProgram terminated!"
getchar();
return 0;
}
The output is as follows:
C:\WINDOWS\HIMEM.SYS
Foreign Currency Conversion Program
===================================
Selection: Currency:
----------------------
1. ÖÖÖÖÖ%@8
2.
3.
4.
5.
6. Exit
Program terminated!
what am I doing wrong?