Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
im so sorry..here the list of error that appear:
C:\Users\PidMin\Desktop\last.cpp In function `int main()':
161 C:\Users\PidMin\Desktop\last.cpp expected `while' before '}' token
161 C:\Users\PidMin\Desktop\last.cpp expected `(' before '}' token
161 C:\Users\PidMin\Desktop\last.cpp expected primary-expression before '}' token
161 C:\Users\PidMin\Desktop\last.cpp expected `)' before '}' token
161 C:\Users\PidMin\Desktop\last.cpp expected `;' before '}' token
C++
#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);
}
}
}
}
Posted
Updated 17-Apr-15 22:59pm
v3
Comments
Suvendu Shekhar Giri 18-Apr-15 2:23am    
Can't run means? Is it giving any error? if so share the error. Little more information about your problem could help people understanding your actual problem.
Member 11306844 18-Apr-15 4:57am    
im so sorry..here the list of error that appear:
C:\Users\PidMin\Desktop\last.cpp In function `int main()':
161 C:\Users\PidMin\Desktop\last.cpp expected `while' before '}' token
161 C:\Users\PidMin\Desktop\last.cpp expected `(' before '}' token
161 C:\Users\PidMin\Desktop\last.cpp expected primary-expression before '}' token
161 C:\Users\PidMin\Desktop\last.cpp expected `)' before '}' token
161 C:\Users\PidMin\Desktop\last.cpp expected `;' before '}' token
OriginalGriff 18-Apr-15 2:48am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.

And while you are at it, do yourself a favour and indent your code...
Richard MacCutchan 18-Apr-15 3:34am    
You are corrupting your memory by addressing buf[17], which is the 18th element of a 17 element array. There are probably other things wrong, which I have not spotted.
Member 11306844 18-Apr-15 4:47am    
im so sorry..here the list of error that appear:
C:\Users\PidMin\Desktop\last.cpp In function `int main()':
161 C:\Users\PidMin\Desktop\last.cpp expected `while' before '}' token
161 C:\Users\PidMin\Desktop\last.cpp expected `(' before '}' token
161 C:\Users\PidMin\Desktop\last.cpp expected primary-expression before '}' token
161 C:\Users\PidMin\Desktop\last.cpp expected `)' before '}' token
161 C:\Users\PidMin\Desktop\last.cpp expected `;' before '}' token

1 solution

The statement
C++
while (((!feof(DS) && (curPos<seek_end))));>

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.
 
Share this answer
 
Comments
Maciej Los 19-Apr-15 14:41pm    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900