Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4037218
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:19:12+00:00 2026-05-20T12:19:12+00:00

I have the user enter a keyword which is broken up and put into

  • 0

I have the user enter a keyword which is broken up and put into a five by five array, then another function called “getletter” which fills up the rest of the spaces in the array in alphabetical order excluding those letters already included in the keyword. When I try to pass the values of the keyword to the getletter function it doesn’t work.

#include<iostream>
#include<fstream>
#include<cstdlib>
#include<string>
#include<limits>

using namespace std;
string getletter();  
char type[81];
char filename[20];
char key [5];

char f[2] = "q";
    char g[2] = "q";
    char h[2] = "q";
    char i[2] = "q";
    char j[2] = "q";
    char k[2] = "q";
    char l[2] = "q";

int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;

int main(){



string cipherarray[5][5]= {
{"a","f","k","p","v"},
{"b","g","l","r","w"},
{"c","h","m","s","x"},
{"d","i","n","t","y"},
{"e","j","o","u","z"}

};





cout<<"Enter the name of a file you want to create.\n";

cin>>filename;

cout<<"enter your codeword(codeword can have no repeating letters)\n"; 

cin>>key;

while (key[a] != '\0' ){

while(b <= 4){
cipherarray[b][c] = key[a];

 if (  f == "q" ) {
 cipherarray[b][c] = f;
}

 if ( f != "q" && g == "q"  )
 {
cipherarray[b][c] = g;
}

 if ( g != "q" && h == "q" )
 {
cipherarray[b][c] = h;
}

 if ( h != "q" && i == "q"  )
 {
cipherarray[b][c] = i;
}


 if ( i != "q" && j == "q" ) 
{
cipherarray[b][c] = j;
}

 if ( j != "q" && k == "q" )
 {
cipherarray[b][c] = k;
}

 if ( k != "q" && l == "q" )
 {
cipherarray[b][c] = l;
}
a++;
b++;
if (key[a] == 0)
break; 
}

if (key[a] != 0){
c++;
b = 0;
}
}

while ( c <= 4) {
while ( b <= 4) {
 cipherarray[b][c] = getletter();
 b++;     
}
b = 0;
c++;
} 










b = 0;
c = 0;

while ( c <= 4) {
while ( b <= 4) {
 cout<<cipherarray[b][c]<<" ";
 b++;     
}
cout<<endl;
b = 0;
c++;
} 






 cout<<"now enter some text."<<endl<<"To end this program press Crtl-Z\n";


ofstream outFile;
outFile.open(filename);
outFile<<fixed;
outFile.precision(2);
outFile.setf(ios_base::showpoint);
cin.ignore(std::numeric_limits<int>::max(),'\n');

while(!cin.fail()){

 cin.getline(type,81);

outFile<<type<<endl;
}

outFile.close();
}





string getletter() {
string letter;
string cipherarraytemplate[5][5]= {
{"a","f","k","p","v"},
{"b","g","l","r","w"},
{"c","h","m","s","x"},
{"d","i","n","t","y"},
{"e","j","o","u","z"}
};


if (cipherarraytemplate[d][e] == f || cipherarraytemplate[d][e] == g || cipherarraytemplate[d][e] == h || cipherarraytemplate[d][e] == i || cipherarraytemplate[d][e] == j ||
 cipherarraytemplate[d][e] == k || cipherarraytemplate[d][e] == l){ 
 d++; 
 } 
 else {
letter = cipherarraytemplate[d][e];
}
d++;
if (d == 5){
e++;
d = 0;
}
return letter;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:19:13+00:00Added an answer on May 20, 2026 at 12:19 pm

    I just set a variable that increases by one each time the loop runs through.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have the user enter a keyword in my app and then
I have a form a user can enter their name, then it will add
I have a GMT field in which the user enter a time to be
I want to open a save file dialog, have the user enter a filename,
I have an aspx page,where the user will enter a valid image url(ex :
I have a web page where the user will enter their address. They will
In my current application I have a form that requires the user to enter
I have a type ahead text field, and when the user hits Enter I
I have user control named DateTimeUC which has two textboxes on its markup: <asp:TextBox
I have a user interface in .net which needs to receive data from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.