功能和变量"鸡肉或鸡蛋"脚本

时间:2014-03-16 22:08:27

标签: c++ ffmpeg

我正在制作一个简单的程序在C ++中运行为我做ffmpeg,但是我遇到了需要在" 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;
            }
    }
}

1 个答案:

答案 0 :(得分:3)

给函数一个参数:

int convert(int operation)
{
    switch(operation){

然后在main中传递一个参数:

int operation = ....
int c = convert(operation);