我已经编写了读取包含37000个DNA序列的文本文件并分析特定模式的序列的代码。但每次我运行的代码时,它说这是我的代码,它返回处理返回255(0xff)codeblocks
codon.exe stopped working and Process returned 255 (0xff)
这是代码:
#include<iostream>
#include<vector>
#include<cstring>
#include<cstdio>
#include<fstream>
using namespace std;
int main()
{
ifstream dnafile;
dnafile.open("code.txt"); /// code.txt is notepad file name
if(!dnafile.is_open())
{
cout<<"file not opened";
}
int c=0;
vector <int> a;
vector <char> codon;
int l=0; /// lTH TERM OF DNA SEQUENCE
char x;
while((x = dnafile.get()) != EOF) /// READING CHARACTER BY CHARACER FROM FILE
{
if(x=='>')
{
l=0;
codon.push_back('#');
continue;
}
l++;
codon.push_back(x);
}
for(int l=0;l<codon.size();l++)
{
if(codon.at(l)=='#')
c++;
}
int c1[c+1];
float b[c+1],d[c+1];
for(int j=0;j<(c+1);j++)
{
for(int i=1;i<a.size();i++)
{
if (a[i]==0&&c1[j]!=0)
{
d[j]=(b[j]+a[i-c1[j]])/c1[j];
i++;
break;
}
else if(c1[j]==0)
d[j]=0;
else
{
b[j]=b[j]+(a[i]-a[i-1]);
}
}
continue;
}
for(int j=0,i=0;j<a.size(),i<(c+1);j=j+c1[i],i++)
{
cout<<"("<<d[i]<<","<<c1[i]<<","<<a[j]<<")"<<", ";
}
return 0;
}
通过使用调试器开始,找到它崩溃的地方。 –
'int c1 [c + 1];'这行看起来像这样的行和行是无效的C++。为什么不使用'vector'?你在其他地方使用它,那么为什么不在这里呢? 'std :: vector c1(c + 1);' –
PaulMcKenzie
即使我将它们声明为向量也不会影响数组,它很容易初始化它们的一些值 –