U
uche
This function that I have implemented gives me an infinite loop. I am
trying to produce a hexdum program, however, this function is not
functioning correctly.....Please help.
void output(unsigned char ret_buffer, int curr_buffer_size, bool&
endoffile)
{
int index2=0;
int addr=0;
unsigned char outBuff[curr_buffer_size];
outBuff[curr_buffer_size] = ret_buffer;
while (!endoffile)
{
cout<<setw(4)<<setfill('0')<<uppercase<<hex<<addr<<"0: "; //
prints mem location
for (int index = 0; index <16; index++)
{
index2++;
if (index2 <= curr_buffer_size)
cout<<hex<<setw(2)<<setfill('0')<<(int)outBuff[index];
else
cout<<" ";
cout<<" ";
}//end for
cout<<setfill(' ');
//cout<< " ");
index2 = 0;
for (int index = 0; index < 16; index ++)
{
index2++;
if (index2 <= curr_buffer_size)
{
if (outBuff[index] < 32 || outBuff[index] > 126)
printf(".");
else
cout<<outBuff[index];
}//end if
}//end for
}
}
trying to produce a hexdum program, however, this function is not
functioning correctly.....Please help.
void output(unsigned char ret_buffer, int curr_buffer_size, bool&
endoffile)
{
int index2=0;
int addr=0;
unsigned char outBuff[curr_buffer_size];
outBuff[curr_buffer_size] = ret_buffer;
while (!endoffile)
{
cout<<setw(4)<<setfill('0')<<uppercase<<hex<<addr<<"0: "; //
prints mem location
for (int index = 0; index <16; index++)
{
index2++;
if (index2 <= curr_buffer_size)
cout<<hex<<setw(2)<<setfill('0')<<(int)outBuff[index];
else
cout<<" ";
cout<<" ";
}//end for
cout<<setfill(' ');
//cout<< " ");
index2 = 0;
for (int index = 0; index < 16; index ++)
{
index2++;
if (index2 <= curr_buffer_size)
{
if (outBuff[index] < 32 || outBuff[index] > 126)
printf(".");
else
cout<<outBuff[index];
}//end if
}//end for
}
}