473,399 Members | 3,603 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,399 software developers and data experts.

How can I fix my compiling error on line 12?

Hi, I need help with my program. How can I fix my compiler error on line 12 of me code? It's not working for some reason. May I have feedback please?
This is the problem:

Your country is at war and your enemies are using a secret code to communicate
with each other. You have managed to intercept a message that
reads as follows:

:mmZ\dxZmx]Zpgy

Write a program that decrypts the intercepted message. You only know
that the key used is a number between 1 and 100. Your program should
try to decode the message using all possible keys between 1 and 100.
When you try the valid key, the message will make sense. For all other
keys, the message will appear as gibberish.

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. void input(char message[100], int& key);
  8. vector<char> encrypt(char message[100], int key);
  9.  
  10. int main()
  11. {
  12.     input(message[100], key);
  13.     vector<char> encrypt(char message[100], key);
  14.  
  15.     return 0;
  16. }
  17.  
  18. void input(char message[100], int& key)
  19.  
  20. {
  21.     cout << "Please enter an encrypted message: \n";
  22.     cin.getline(message,100);
  23. }
  24.  
  25. vector<char> encrypt(char message[100], int key)
  26.  
  27. {
  28.     int counter;
  29.     char output[100];
  30.  
  31.     for(key = 1; key <= 100; key++)
  32.     {
  33.         for(counter = 0; message[counter]! = '\0' ; counter++)
  34.         {
  35.             if(message[counter] - key < 32)
  36.                 output[counter] = message[counter] - key - 32 + 127;
  37.             else
  38.                 output[counter] = message[counter] - key;
  39.         }
  40.  
  41.         cout << "Decrypted message using Key" << key << " : ";
  42.         cout << output << endl;
  43.     }
  44.  
  45. }
May 4 '14 #1
1 1439
divideby0
131 128KB
Expand|Select|Wrap|Line Numbers
  1.  input(message[100], key);
the call here isn't right. you haven't declared any variables named input or key. declare a char array and an integer variable, and pass them as parameters to input.

Expand|Select|Wrap|Line Numbers
  1. char array[100] = { 0 };
  2. int key;
  3.  
  4. input(array, key);
  5.  
Expand|Select|Wrap|Line Numbers
  1. void input(char message[100], int& key)
  2. {
  3. cout << "Please enter an encrypted message: \n";
  4. cin.getline(message,100);
  5. }
the function doesn't appear to change key in any way. are you supposed to alter its value?
May 4 '14 #2

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

Similar topics

2
by: WindAndWaves | last post by:
Is it possible to find out at what line an error occurred for an error log??? --- Please immediately let us know (by phone or return email) if (a) this email contains a virus (b) you are...
1
by: Itzik | last post by:
Hi i have any error in my function can i get only error line Thanks
6
by: bmwrob | last post by:
I’m very new in C++ programming and am trying to make a decoder tool just for the purpose of learning. I started my project in VC++ 6.0, but after a change of PC, I continued my programming in VS...
0
by: tascien | last post by:
How come, the stack trace does not show me the error line? when i run a release version of my asp.net web app? I get something like this: Error Message: Object reference not set to an instance...
2
by: Tony | last post by:
In visual studio 2005, while debugging a new web project in C#, the error line does not show up in the error dialog box. The actual error shows up correctly, but it does not tell me what line it...
0
by: mjm | last post by:
Hi, My script errors when compiling with: SCRIPT: Compiling Error => Line 59 : Expected statement (-2146827264) 'Variables available on this screen can be declared and initialized here. Dim...
0
by: rthimmana | last post by:
Hi We record the error line using the Err_Line() function within the catch block for our procedures. When we open the procedure and check the corresponding line number using a Management...
3
by: Ananthu | last post by:
Hi I have created one website named OTMS using ASP.NET in a File System Format.My project location is in F: drive(F:\Project\OTMS). I have installed IIS properly and the website runs properly in...
9
whatelyb
by: whatelyb | last post by:
I am having trouble related to the attached coding. I am trying to make the object "flight1pic" change depending on what is selected in the drop down menus "airline1" and "aircraft1". My...
4
by: Rylos007 | last post by:
Greetings, first post and in need of some code error help. I am ruff at html and .css skill wise. :) Home Page Good page w/ proper R-sidebar Evil page w/ improper R-sidebar. Error from WC3...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.