函数和变量"chicken or the egg"方案



我正在制作一个简单的程序在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);

相关内容

  • 没有找到相关文章

最新更新