mercredi 25 septembre 2019

Can't Call Function Within Switch Case - C++

I am trying to run encryption program of some sort but i can't call void enc, Source Code:

#include <iostream>
#include <conio.h>
#include <windows.h>
#include <algorithm>
#include <string>

using namespace std;

int x,y,z,a,b,c,n;
char tabs[26][26],temp[512];
string input,output,Key;

void open();
void tableau();
void inchar();
void enc();
void dec();

int main() {
  open();
  cout << "1.\tEncrypt \n2.\tDecrypt \nOption: "; cin >> a;
  switch (a) {
    case 1:
      enc(); cout << a << "Debugger";
      break;
    case 2:
      dec();
    break;
  }
  return 0;
}

void enc(){
  void open();
  void inchar();
}

void dec(){

}

void inchar(){
  cout << "input: "; cin >> input; z = input.size();
  char dispos[input.size() + 1];
  copy(input.begin(),input.end(),dispos); dispos[input.size()] = '\0';
  for (int i = 0; i < z; i++) {
    temp[i] = dispos [i];
  }
}

void tableau() {
  cout << "Initialize Table Construct!!" << endl;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 26; j++) {
      x = (i + j) % 26; y = x + 65;
      tabs[i][j] = y;
      cout << tabs[i][j] << " ";
    }
    cout << endl;
  }
}

void open() {
  cout << "Well Hello There";
}

every time i choose option 1 the debugger cout kept on appearing. if the debugger is erased then the code just end.

P.S: I've done moving the function call to before the switch but still it does nothing. P.S.S: Sorry for bad English.

Aucun commentaire:

Enregistrer un commentaire