无法在开关大小写中调用函数 - C++
Can't Call Function Within Switch Case - C++
我正在尝试运行某种加密程序,但我无法通过开关函数调用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()] = ' ';
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 时,调试器 cout 都会不断出现。 如果调试器被擦除,则代码就会结束。
PS:我已经完成了将函数调用移动到切换之前,但它仍然什么也没做。 PS:对不起,英语不好。
问题是你的enc()
函数被调用了,但它什么也没做!语法错误:
void enc(){
void open(); // These lines DECLARE two NEW function ...
void inchar(); // ... without ever calling them!
}
要调用这两个函数,请使用以下命令:
void enc(void) {
open();
inchar();
}
相关文章:
- 如何用参数值调用函数(仅在运行时已知)
- 从python中调用C++函数并获取返回值
- 当使用通配符和null指针调用函数时,对输出的说明
- 从R调用C++函数并对其进行集成时出错
- 使用QTreeView,如何通过调用函数只突出显示特定的行/列
- 如何在qt中从另一个类调用函数
- 在 COUT 语句中使用 COUT 调用函数
- 如何从线程中的不同模块调用函数?
- C++从函数指针数组调用函数
- 当 A 在 for 循环中调用函数 B 时,如何计算函数 A 的空间复杂度?
- 如何在 C/C++ 中从外部库调用函数
- 如何使用运算符在同一行中多次调用函数
- 是否可以创建一个从不同类调用函数的线程?
- 无法为类成员调用函数
- 如何从另一个标头 c++ 调用函数
- C++有什么方法可以在既不调用函数模板也不提供其模板参数的情况下引用函数模板?
- 如何只允许在调用函数 B 后调用函数 A?
- 我可以这样调用函数吗?
- 如何在 c++ 的类中递归调用函数方法?
- 为什么在指向对象的迭代器上调用函数不允许我更改对象本身?