无法在开关盒内调用函数-C ++

问题描述 投票:2回答:1

我正在尝试运行某种加密程序,但无法通过switch函数调用void enc,源代码:

#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";
}

每次选择选项1时,debugger cout都会不断出现。如果调试器被删除,则代码刚刚结束。

P.S:我已经完成了将函数调用移到切换之前的操作,但是仍然没有任何作用。P.S.S:对不起,英语不好。

c++ function oop c++11 switch-statement
1个回答
4
投票

问题是您的enc()函数is

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.