朋友鸡 2019-08-12 22:08 采纳率: 0%
浏览 242

为什么编译突然无效?

今天遇到一个诡异的问题,稍微分享一下,目前没找到原因。
之前Playsound函数好不容易搞懂,于是在程序里加了一个声音。
之后,我把这行代码删掉,编译运行后还是一个样。这时我还没怎么在意,用查找功能,发现我的这个程序里根本没有Playsound。于是我知道了事情的严重性。我把main函数里面的东西全删光,编译运行后还是这样!
我怕编译器不能自己覆盖文件了,于是把exe也删掉。编译运行后,还是这样!我把这些代码放在其他文件上没事,放这里就有事了!
我的DEVc++怕不是有毒!
之前(此时Playsound已经被删):

#include"psw.cpp"
#include<cstdio>
#include <string>
#include <stdlib.h>
#include <windows.h>
#include <mmsystem.h>
#pragma comment(lib,"winmm.dll.lib")
#include<direct.h>
#include<algorithm>
#include<conio.h>
//#include<bits/stdc++.h>
//using namespace std;
class wordcard{
    public:
    string first_heading;
    string second_heading;
    string word;
    string meaning;
    string sound; 
    int pre;
    int next;
    void give(string a,string b,string c,string d,int n,string e=""){
        first_heading=a;
        second_heading=b;
        word=c;
        meaning=d;
        sound=e;
        pre=n-1;
        next=n+1;
    }
    void Clear()
    {
        first_heading="";
        second_heading="";
        word="";
        meaning="";
    }
}word[100000],tword[100000];

string get_path()
{
    char buffer[10000];
    getcwd(buffer,10000);
    string ans=buffer;
    return ans;
}

bool Change=true,Round=true;
string listname[10000],tstr,first[2],second[2];
int p,tn,pp,head,nlist;
bool lock=1;
int main(){
    srand(time(NULL));
    while(Round)
    {
        if(Change)
        {
            while(1)
            {
                cout<<"listname of the next list:";
                cin>>tstr;
                if(tstr=="LOCK.")
                    lock=1;
                else if(tstr=="UNLOCK.")
                    lock=0;
                else
                    break;
            }
            nlist=pswstr::sprt(tstr,listname,'+');
            p=0;
            for(int i=0;i<nlist;i++)
            {
                listname[i]+=".txt";
                ifstream file1;
                file1.open(listname[i].data());
                cout<<listname[i]<<" has been opened."<<endl;
                while(1)
                {
                    file1>>tstr;
                    if(tstr=="EOF")
                        break;
                    else if(tstr[0]=='$')
                        pswstr::sprt(tstr,first,'$');
                    else if(tstr[0]=='#')
                        pswstr::sprt(tstr,second,'#');
                    else
                    {
                        tword[p].give(first[0],second[0],tstr,"",p);
                        file1>>tstr;
                        tword[p++].meaning=tstr;
                    }
                }
                file1.close();
                cout<<listname[i]<<" 's words have been loaded."<<endl;
                //system("cls");
            }
        }
        for(int i=0;i<100000;i++)
            word[i]=tword[i];
        head=0;
        for(int i=0;i<p;i++)
        {
            pp=head;
            tn=rand()%(p-i);
            for(int j=0;j<tn;j++)
                pp=word[pp].next;
            cout<<word[pp].first_heading<<endl<<word[pp].second_heading<<endl<<word[pp].word<<endl;
            getch();
            cout<<word[pp].meaning<<endl<<endl<<endl;
            // -lwinmm

            if(!lock)
            {
                cout<<" if you want to delete, type d/D";
                int tch = getch();
                if(tch!='d' && tch!='D')
                {
                    tword[word[pp].pre].next=tword[pp].next;
                    tword[word[pp].next].pre=tword[pp].pre;
                }
            }
            else
                getch();
            system("cls");
            if(word[pp].pre==-1)
            {
                head=word[pp].next;
                word[head].pre=-1;
            }
            else
            {
                word[word[pp].pre].next=word[pp].next;
                word[word[pp].next].pre=word[pp].pre;
            }
        }
        cout<<"End of the list!"<<endl<<"Do you want to try again?(any input except C or E)or change the list?(C) or just exit?(E)"<<endl<<"write your choice(.../C/E):";
        cin>>tstr;
        if(tstr=="E")
            Round=false;
        else if(tstr=="C")
            Change=true;
        else
        {
            Change=false;
        }

        system("cls");
    }
}

之后:

#include"psw.cpp"
#include<cstdio>
#include <stdlib.h>
#include <windows.h>
#include <mmsystem.h>
#pragma comment(lib,"winmm.dll.lib")
#include<direct.h>
#include<algorithm>
#include<conio.h>
//#include<bits/stdc++.h>
//using namespace std;
class wordcard{
    public:
    string first_heading;
    string second_heading;
    string word;
    string meaning;
    string sound; 
    int pre;
    int next;
    void give(string a,string b,string c,string d,int n,string e=""){
        first_heading=a;
        second_heading=b;
        word=c;
        meaning=d;
        pre=n-1;
        next=n+1;
    }
    void Clear()
    {
        first_heading="";
        second_heading="";
        word="";
        meaning="";
    }
}word[100000],tword[100000];

string get_path()
{
    char buffer[10000];
    getcwd(buffer,10000);
    string ans=buffer;
    return ans;
}

bool Change=true,Round=true;
string listname[10000],tstr,first[2],second[2];
int p,tn,pp,head,nlist;
bool lock=1;
int main(){
}

——————————————
现在我把原音频删掉,结果还在响!
但是我不用编辑器而是直接点开exe文件时就发现exe正常了。
——————————————
我把代码删得只剩int main(),它还在响...

  • 写回答

1条回答 默认 最新

  • 关注
    评论

报告相同问题?

悬赏问题

  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)