问题描述
我很抱歉..出现的错误列表:
C:\ Users \PidMin\Desktop\last.cpp函数`int main() ':
161 C:\ Users \ PidMin \Desktop\last.cpp预期'而''之前'}'令牌
161 C:\ Users \ PidMin \Desktop\last.cpp期望`(''''}'令牌
161 C:\ Users \PidMin \Desktop\last.cpp期望的primary-expression之前'}'令牌
161 C:\ Users \ PidMin \Desktop\last.cpp预期`)''}'}'令牌
161 C:\\ \\ Users \ PidMin \Desktop \last.cpp expect';'before'}'token
#include <fstream>
#include <stdio.h>
#include <string>
#include <time.h>
#include <conio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
// **************************************************************************************************************************************
int main(void)
{
// >>> Declaration **********************************************************************************************************************
time_t start, end;
double duration=0;
char dataSet[50], auditTrail[50];
FILE *DS, *AT;
long int size=0L, curPos=0L;
unsigned char c;
int i, total_detil=0, total_E0_E1E2=0, total_E0_DB=0, total_DB=0, total_C4=0, total_E1=0, total_embed=0, total_ori=0, total_tn=0;
system("cls"); // clear the screen
// >>> Read string from DFRWS**********************************************************************************************************
strcpy(dataSet, "C:\\Users\\dfrws-2007-challenge.img");
if ((DS = fopen(dataSet, "rb"))==NULL)
{
printf("Failed to open %s!",dataSet);
getch();
exit(1);
}
// >>> Read string to data file********************************************************************************************************
strcpy(auditTrail, "C:\\Users\\dfrws-2007-challenge.img.txt");
// >>> Open binary file to be written***************************************************************************************************
if ((AT = fopen(auditTrail, "wb"))==NULL)
{
printf("Failed to open %s!",auditTrail);
getch();
exit(1);
}
// >>> Get ready to start***************************************************************************************************************
fseek(DS, 0L, SEEK_END);
size=ftell(DS);
fseek(DS, 0L, SEEK_SET);
start=time(NULL); // START timer
// >>> START algorithm processing********************************************************************************************************
FILE * pFile;
pFile = fopen ("e_mykarve_datafile5.txt","w");
//
int IDX = 0;
unsigned buf[17]; char BUF;
for (i=0; i<17; i++) buf[i] = 0;
//
printf("________________________________START_________________________________\n");
do
{
c = fgetc(DS);
//printf("\n%x.",c);
/// ============================================== start
if (IDX<17) {
buf[IDX] = c;
}
else
{
buf[0] = buf[1];
buf[1] = buf[2];
buf[2] = buf[3];
buf[3] = buf[4];
buf[4] = buf[5];
buf[5] = buf[6];
buf[6] = buf[7];
buf[7] = buf[8];
buf[8] = buf[9];
buf[9] = buf[10];
buf[10] = buf[11];
buf[11] = buf[12];
buf[12] = buf[13];
buf[13] = buf[14];
buf[14] = buf[15];
buf[15] = buf[16];
buf[16] = buf[17];
buf[17] = c;
}
++IDX;
// >>> CHECK JPEG MARKER
if( !( ( buf[0] == 0x25 ) && ( buf[1] == 0x25 ) ))
{
if ( buf[0] == 0x25 )
{
if ( buf[1] == 0x50)
{
if ( buf[2] == 0x44 )
{
if ( buf[3] == 0x46 )
{
curPos=ftell(DS)-3;
printf("\n<soi original="" e1=""> at offset address %ld",curPos-1L);
fprintf(pFile, "25504446\t%ld\n",curPos-1L);
total_ori=++total_ori;
total_E1=++total_E1;
if ( !( ( buf[0] == 0x45 ) && ( buf[1] == 0x45 ) ))
if ( buf[0] == 0x45 )
{
if ( buf[1] == 0x45)
{
if ( buf[2] == 0x46 )
curPos=ftell(DS)-3;
printf("\n<eof original="" e1=""> at offset address %ld",curPos-1L);
fprintf(pFile, "454F46\t%ld\n",curPos-1L);
total_ori=++total_ori;
total_E1=++total_E1;
}
}
}
}
while (((!feof(DS)&&(curPos<seek_end))));>
}
end=time(NULL);
duration=difftime(end,start);
//start of report
printf ("\nStart: ");
printf (ctime(&start));
printf ("\nFinish: ");
printf (ctime(&end));
duration=difftime (end, start);
printf ("Duration: %.2f sec",duration);
printf ("\nSize of Data Set: %ld bytes", size);
//end
getch();
fclose(DS);
fclose(AT);
return (0);
}
}
}
}
推荐答案
while (((!feof(DS) && (curPos<seek_end))));>
在错误的地方。它位于 if
子句的末尾,而不是从第65行开始的 do
子句。你有什么东西如果你在你的代码上使用了适当的缩进,我们很容易发现你自己。
另请注意你的 buf 仍然是一个元素短。
同样使用名称 buf
表示数组,并且 BUF
对于一个字符变量来说,这不是最合理的名称选择。
is in the wrong place. It is at the end of an if
clause, rather than the do
clause which starts at line 65. Something that you could easily spot for yourself if you had used proper indentation on your code.
Also note that your declaration of buf
is still one element short.
Also using the name buf
for an array, and BUF
for a character variable is not the most sensible choice of names.
这篇关于无法运行此代码..为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!