对C4droid的主要重定义错误

时间:2013-03-13 17:59:39

标签: android c++ gcc g++

我在我的Android设备上使用c4droid(c ++)(g ++ +仿生编译器),之前工作的代码,在2-3小时后运行,发出错误!!

说真的,对这个错误一无所知,但有一点观察,在重新安装应用程序时,我看到问题消失了,但是暂时!

    // program with file handling search , display and modify functions
    #include<iostream>
    #include<fstream>
    #include<string>
    using namespace std;
    ofstream f("bank.dat", ios::app);

     int n = 0, flag = 0;
     struct bac
         {
           char name[10];
           char amt[5];
          } s;

    void add()
    { 
        cout << "\nenter the details ";
        cin >> s.name >> s.amt;
        f.write((char *)&s, sizeof(bac));

    }

    void ser()
    {
        ifstream fa("bank.dat");
        fa.seekg(0);
        char x[10];
        cout << "\nenter value to be searched ";
        cin >> x;

        while (fa && flag == 0)
        {
            n++;
        fa.read((char *)&s, sizeof(bac));
        if (strcmp(s.name, x) == 0)
        {
            flag = 1;
            break;
        }
    }
    if (flag == 1)
    {
        cout << "\nfound";
        cout << "\nAmount " << s.amt;
    }


}

void mod()
{
    ser();
    cout<<" "<<n;
    if (flag == 1)
    {
        f.seekp((n - 1) * sizeof(bac));
    //  cout<<f.tellp();
        cout<<"\nnew details ";
        add();
        }
    }


    int main()
    {f.seekp(0);
        int ch;

            cout << "\nBANK MANAGEMENT SYSTEM \n";
            cout << "enter choice ";
            cout << "\n1.add\n2.search\n3.delete and overwrite ";
            cin >> ch;
            if (ch == 1)
            {
                add();
            }
            if (ch == 2)
            {
                ser();
            }
            if (ch == 3)
            {
                mod();
            }

        return 0;
    }

更新

即使这个程序也会出现同样的错误

#include<iostream>
using namespace std;
int main()
{
return 0;
}

错误 错误:由于-Wfatal错误重新定义'int main()'编译 - 错误 -

代码在逻辑上是不正确的,但确实用于编译! 我需要知道导致问题的原因是什么,以及代码早期编译和运行时也是如此!

1 个答案:

答案 0 :(得分:0)

我很可能在您的程序所在的目录中有一个名为系统头的源代码。 重新安装应用程序并重命名并将文件传输到其他位置就可以了解