473,320 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Compiler Error- Overloaded function, invalid conversion

I am working on a program to "encrypt" a text file supplied by the user, and writing to another file also given by the user. I am very new to programming and am having trouble passing information from file to program and back to file. I am close, but I have comiler errors. Here is my code so far:


Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <cctype>
  3. #include <fstream>
  4. #include <iomanip>
  5. using namespace std;
  6.  
  7. //Function: displayHeader
  8. //Description: Outputs program header to screen
  9. //Inputs: None
  10. //Outputs: Header to screen
  11. //Usage: displayHeader()
  12. void displayHeader();
  13.  
  14. void getFile(char& fileIn, char& fileOut);
  15.  
  16. char charShift (char toEncrypt);
  17.  
  18. char encrypt(char symbol);
  19.  
  20. bool firstHalf(char symbol);
  21.  
  22. int main()
  23. {
  24.   char fileIn[13];
  25.   char fileOut[13];
  26.   char runAgain;
  27.   ifstream file1;
  28.   ofstream file2;
  29.   displayHeader();
  30.   do
  31.   {
  32.     void getFile(char& fileIn, char& fileOut);
  33.     ifstream file1(fileIn[]);
  34.     if (!file1||!file2)
  35.     {
  36.       cout << "Error opening input file." << endl;
  37.     }
  38.     char encrypt(file1);
  39.     file1.close;
  40.     file2.close;
  41.     cout << "Would you like to run program again? (y/n)" << endl;
  42.     cin >> runAgain;
  43.   }
  44.   while (runAgain=='Y'||runAgain=='y');
  45. }
  46.  
  47. void getFile(char& fileIn, char& fileOut)
  48. {
  49.   cout << "Please enter name of file to be encrypted." << endl;
  50.   cin >> fileIn;
  51.   cout << "Please enter file to write to." << endl;
  52.   cin >> fileOut;
  53. }
  54.  
  55. char encrypt(char symbol)
  56. {
  57.   char encryptChar;
  58.   char nextCh;
  59.   nextCh=symbol;
  60.   file1.get(nextCh);
  61.   while (!file1.eof())
  62.   {
  63.     if (isalpha(nextCh))
  64.     {
  65.       encyptChar=charShift(nextCh);
  66.       file2 << encryptChar;
  67.     }
  68.     else
  69.     {
  70.       file2 << nextCh;
  71.     }
  72.   }
  73. }
  74.  
  75. char charShift(char toEncrypt)
  76. {
  77.   if (firstHalf(toEncrypt))
  78.   {
  79.     return toEncrypt+13;
  80.   }
  81.   else
  82.   {
  83.     return toEncrypt-13;
  84.   }
  85. }
  86.  
  87. bool firstHalf(char symbol)
  88. {
  89.  if((symbol>='A'&&<='M')||(symbol>='a'&&<='m'))
  90.   {
  91.     return 1;
  92.   }
  93.   else
  94.   {
  95.     return 0;
  96.   }
  97. }
  98.  
To which I receive these following compiler errors:

Here (Photo)

any help would be useful, thanks
Nov 9 '06 #1
1 2194
Banfa
9,065 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1.     void getFile(char& fileIn, char& fileOut);
  2.  
This is not a function call it is a function definition and as such does nothing so fileIn and fileOut are still uninitialised. It should be
Expand|Select|Wrap|Line Numbers
  1.     getFile(fileIn, fileOut);
  2.  
Expand|Select|Wrap|Line Numbers
  1.     ifstream file1(fileIn[]);
  2.  
The square brackets are a syntax error in this line remove them

Expand|Select|Wrap|Line Numbers
  1.  
  2. void getFile(char& fileIn, char& fileOut)
  3. {
  4.  <snipped>
  5. }
  6.  
You have declared references to a char but are trying to pass a char array into this function, either declare them as pointers
Expand|Select|Wrap|Line Numbers
  1.  
  2. void getFile(char *fileIn, char *fileOut)
  3. {
  4.  <snipped>
  5. }
  6.  
or declare them as references to char array

Expand|Select|Wrap|Line Numbers
  1.  
  2. void getFile(char (&fileIn)[13], char (&fileOut)[13])
  3. {
  4.  <snipped>
  5. }
  6.  
Expand|Select|Wrap|Line Numbers
  1.     char encrypt(file1);
  2.  
the char is wrong and you pass a char array to encrypt

Expand|Select|Wrap|Line Numbers
  1. char encrypt(char symbol)
  2. {
  3.     <snipped>
  4. }
  5.  
But it is defined as accepting a char
Nov 9 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: paul calvert | last post by:
I hope somewhere here has encountered and solved a similar problem in the past. 1) on a new Win2000 PC: installed Visual C++ 6.0 download & install single file Service Pack 5.0 2) try to...
2
by: Mike Fisher | last post by:
I'm seeing an error when I try to run/debug a web service. Although it doesn't happen every time, it does occur more than half of the times I hit F5. It appears to be returned by the the JIT...
30
by: Neil Zanella | last post by:
Hello, Allow me to share my frustrations with GNU g++. This is the second time something similar happens to me: I can't find anything wrong with my C++ program and yet I get segfaults, and...
16
by: pj | last post by:
(Was originally, probably wrongly, posted to the vc subgroup.) (This doesn't appear to be a c# problem, but a problem with a bug in the Visual Studio c# compiler, but, any help will be welcome...)...
0
by: rollasoc | last post by:
Hi, I seem to be getting a compiler error Internal Compiler Error (0xc0000005 at address 535DB439): likely culprit is 'BIND'. An internal error has occurred in the compiler. To work around...
1
by: Ayende Rahien | last post by:
reparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error (0xc0000005 at address 53168B12): likely culprit is 'BIND'. An internal...
3
by: Mark Rockman | last post by:
------ Build started: Project: USDAver2, Configuration: Debug .NET ------ Preparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error...
4
by: David Sworder | last post by:
Consider the following line of code (it's not important what it does): resp.DocItem=Relations.SelectDocItems_BySearchString(req.SearchPhrase); It turns out that this line is in error. The...
6
by: David Lack | last post by:
Hi, I recently installed a 60-day trial of .NET 2003 on my development system. I made tests with previous personal projects (which compiled ok with VC6) and some open source files, and keep...
1
by: kvarada | last post by:
Hello Experts, I am building my application on WinNT.4.0_i386_MSVC.7.1 platform. When I build the application on a stand alone machine, it builds fine. But when I build the same application from a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.