函数和变量"chicken or the egg"方案
function and variable "chicken or the egg" scenario
我正在制作一个简单的程序在c++中运行为我做ffmpeg,但我有需要在"main"中定义的某些变量的问题,但该函数需要在main之上准备使用。我能做什么?
#include <iostream>
#include <cstdlib>
using namespace std;
int convert()
{
int operation;
switch(operation){
case '1':
case '2':
case '3':
case '4':
;
}
return 0;
}
int main()
{
std::string formatIn;
std::string FormatOut;
std::string confirm;
cout << "select format that file is currently in: mp3, gp3, mp4, flv" << endl;
cin >> formatIn;
cout << "original format = " << formatIn << endl;
cout << "choose your target format: mp3, gp3, mp4, flv" << endl;
cin >> FormatOut;
cout << "selected format = " << FormatOut << endl;
cout << "proceed? ";
cin >> confirm;
if(confirm == "yes"){
cout << "proceeding with operation:" << endl;
convert();
}
else{
if(confirm == "no"){
cout << "canceling,,," << endl;
}
}
}
给函数一个参数:
int convert(int operation)
{
switch(operation){
然后在main
中传递一个参数:
int operation = ....
int c = convert(operation);
相关文章:
- 这对"With a stackless coroutine, only the top-level routine may be suspended."意味着什么
- Doees the 'this' 指针参与虚函数的多态行为
- 为什么我会收到"Run-Time Check Failure #2 - Stack around the variable 'pr' was corrupted"错误?
- 您将如何连接"on the fly"文本+整数并将其传递给函数?
- 如何理解"Temporary objs are destroyed as the last step in evaluating the full-expression"?谁能用一些简单的例子来说明这
- 如何解决C++中声纳库贝静态代码分析错误"Explicitly define the missing copy constructor, move constructor .."
- Configuring the MPEG4MediaSink
- 这在C++ "It does not own the underlying data, and so is cheap to copy or assign"中意味着什么
- What is the std::chrono::time_point equivalent of std::numer
- 如何在数据库程序中添加"reduce the quantity of an item"功能?
- 使用自定义 nodejs 插件时的"The specified module could not be found"
- Boost.Python 和导入 dll,"The specified module could not be found"
- "Build succeeded"但"The breakpoint will not currently be hit"
- 尝试应用肖恩父母谈话"inheritance is the base class of evil"中的模式
- 为什么'allocate in one library and free in the other'是错误的
- 如何修复此错误"the value of 'x1' is not usable in a constant expression"?static_assert
- Count the digits
- 加载安全区图像"A device attached to the system is not functioning"
- 标头声明"The chicken or the egg"
- 函数和变量"chicken or the egg"方案