Hello, all,
I'm learning about passing function parameters in c++, but I'm having no luck doing so with the code below. Has anyone else had difficulties passing such things with xcode? Or have I missed something really dumb in the code?
(I've already turned this assignment in, but need to figure out how to do this properly for future assingments.)
Thanks for looking.
I'm learning about passing function parameters in c++, but I'm having no luck doing so with the code below. Has anyone else had difficulties passing such things with xcode? Or have I missed something really dumb in the code?
(I've already turned this assignment in, but need to figure out how to do this properly for future assingments.)
Thanks for looking.
Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
char get_Data(ifstream& in_File, char& romanLet); /* gets Roman numbers, character by character, from input file*/
void print_Roman(ofstream& out_File, char& romanLet); /* prints each Roman character to out_File as it's read into file*/
int main ()
{
// Declare variables
char roman1;
int deci;
int decimal1;
int decimal2;
char operator;
int mathResult;
ifstream mp4romanletrdata;
ofstream outRoman;
// Open file
mp4romanletrdata.open("/Users/rob/getDataFunction/build/Release/mp4romanletrdata");
outRoman.open("outRoman");
// Test opening
if (!mp4romanletrdata || !outRoman)
{ cout << "Unable to open files." << endl;
cout << "Program terminates." << endl;
}
do {
outRoman << "The first Roman Number is " ;
// Calculate first number
do {
roman1 = get_Data(mp4romanletrdata, roman1);
if (roman1 != ' ')
print_Roman(outRoman, roman1);
decimal1 += convert_Roman_to_Decimal(roman1, deci);
}
while (roman1 != ' ');
outRoman << " ( " << decimal1 << " )." << endl;
outRoman << "The second Roman Number is " ;
.// there's more to the program, but this is the beginning of my trouble
.
.
return 0;
}
/*****************************************************
BEGIN
get_Data Function:
*****************************************************/
char get_Data(ifstream& in_File, char& romanLet)
{
char romanLetter;
// Get data char from input file
if (in_File.get(romanLetter))
return romanLetter;
else return ' ';
}/****************************************************
END
get_Data
******************************************************/
/*****************************************************
BEGIN
void print_Roman:
*****************************************************/
void print_Roman(ofstream& out_File, char& romanLet)
{
char romanLetter; // sent from get_Data
out_File << romanLetter; // decimal value totaled in main
}/****************************************************
END
void print_Roman
******************************************************/