今天遇到一个诡异的问题,稍微分享一下,目前没找到原因。
之前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(),它还在响...