473,385 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

invalid types `unsigned char[int]' for array subscript

Please give me some feed back on this issue:
Here is the complier error:
hexdmp.cpp: In function `void output(unsigned char, int, bool&)':
hexdmp.cpp:133: error: invalid types `unsigned char[int]' for array
subscript
hexdmp.cpp:146: error: invalid types `unsigned char[int]' for array
subscript
hexdmp.cpp:146: error: invalid types `unsigned char[int]' for array
subscript
hexdmp.cpp:149: error: invalid types `unsigned char[int]' for array
subscript
Here is the code:

while (!endoffile)
{
cout<<setw(4)<<setfill('0')<<uppercase<<hex<<addr< <"0: ";
for (int index = 0; index <16; index++)
{
index2++;
if (index2 <= curr_buffer_size)
cout<<hex<<setw(2)<<setfill('0')<<(int)ret_buffer[index];
else
cout<<" ";
cout<<" ";
}//end for
cout<<setfill(' ');
//cout<< " ");
index2 = 0;
for (int index = 0; index < 16; index ++)
{
index2++;
if (index2 <= index)
{
if (ret_buffer[index] < 32 || ret_buffer[index] 126)
printf('.');
else
cout<<ret_buffer[index];
}//end if
}//end for

Feb 26 '07 #1
3 14505
uche wrote:
Please give me some feed back on this issue:
Here is the complier error:
hexdmp.cpp: In function `void output(unsigned char, int, bool&)':
hexdmp.cpp:133: error: invalid types `unsigned char[int]' for array
subscript
hexdmp.cpp:146: error: invalid types `unsigned char[int]' for array
subscript
hexdmp.cpp:146: error: invalid types `unsigned char[int]' for array
subscript
hexdmp.cpp:149: error: invalid types `unsigned char[int]' for array
subscript
Well, the first question that comes to mind is, which lines are lines
133, 146, and 149?

Post a minimal *COMPILABLE* example that exhibits the error. We don't
know the definitions of your variables, or what lines are generating the
error.

I'm guessing that it's complaining about ret_buffer[index], but without
context we can't be sure.

>
Here is the code:

while (!endoffile)
{
cout<<setw(4)<<setfill('0')<<uppercase<<hex<<addr< <"0: ";
for (int index = 0; index <16; index++)
{
index2++;
if (index2 <= curr_buffer_size)
cout<<hex<<setw(2)<<setfill('0')<<(int)ret_buffer[index];
else
cout<<" ";
cout<<" ";
}//end for
cout<<setfill(' ');
//cout<< " ");
index2 = 0;
for (int index = 0; index < 16; index ++)
{
index2++;
if (index2 <= index)
{
if (ret_buffer[index] < 32 || ret_buffer[index] 126)
printf('.');
else
cout<<ret_buffer[index];
}//end if
}//end for
Feb 26 '07 #2
On Feb 25, 11:35 pm, red floyd <no.s...@here.dudewrote:
uche wrote:
Please give me some feed back on this issue:
Here is the complier error:
hexdmp.cpp: In function `void output(unsigned char, int, bool&)':
hexdmp.cpp:133: error: invalid types `unsigned char[int]' for array
subscript
hexdmp.cpp:146: error: invalid types `unsigned char[int]' for array
subscript
hexdmp.cpp:146: error: invalid types `unsigned char[int]' for array
subscript
hexdmp.cpp:149: error: invalid types `unsigned char[int]' for array
subscript

Well, the first question that comes to mind is, which lines are lines
133, 146, and 149?

Post a minimal *COMPILABLE* example that exhibits the error. We don't
know the definitions of your variables, or what lines are generating the
error.

I'm guessing that it's complaining about ret_buffer[index], but without
context we can't be sure.
Here is the code:
while (!endoffile)
{
cout<<setw(4)<<setfill('0')<<uppercase<<hex<<addr< <"0: ";
for (int index = 0; index <16; index++)
{
index2++;
if (index2 <= curr_buffer_size)
cout<<hex<<setw(2)<<setfill('0')<<(int)ret_buffer[index];
else
cout<<" ";
cout<<" ";
}//end for
cout<<setfill(' ');
//cout<< " ");
index2 = 0;
for (int index = 0; index < 16; index ++)
{
index2++;
if (index2 <= index)
{
if (ret_buffer[index] < 32 || ret_buffer[index] 126)
printf('.');
else
cout<<ret_buffer[index];
}//end if
}//end for
void output(unsigned char ret_buffer, int curr_buffer_size, bool&
endoffile)
{
int index2=0;
int addr=0;

while (!endoffile)
{
cout<<setw(4)<<setfill('0')<<uppercase<<hex<<addr< <"0: ";
for (int index = 0; index <16; index++)
{
index2++;
if (index2 <= curr_buffer_size)
133*
cout<<hex<<setw(2)<<setfill('0')<<(int)ret_buffer[index];
else
cout<<" ";
cout<<" ";
}//end for
cout<<setfill(' ');
//cout<< " ");
index2 = 0;
for (int index = 0; index < 16; index ++)
{
index2++;
if (index2 <= index)
{
146* if (ret_buffer[index] < 32 || ret_buffer[index] 126)
printf(".");
else
149* cout<<ret_buffer[index];
}//end if
}//end for
}
}//end output

Feb 26 '07 #3
On Feb 26, 12:55 pm, "uche" <uraniumore...@hotmail.comwrote:
On Feb 25, 11:35 pm, red floyd <no.s...@here.dudewrote:
uche wrote:
Please give me some feed back on this issue:
Here is the complier error:
hexdmp.cpp: In function `void output(unsigned char, int, bool&)':
hexdmp.cpp:133: error: invalid types `unsigned char[int]' for array
subscript
hexdmp.cpp:146: error: invalid types `unsigned char[int]' for array
subscript
hexdmp.cpp:146: error: invalid types `unsigned char[int]' for array
subscript
hexdmp.cpp:149: error: invalid types `unsigned char[int]' for array
subscript
Well, the first question that comes to mind is, which lines are lines
133, 146, and 149?
Post a minimal *COMPILABLE* example that exhibits the error. We don't
know the definitions of your variables, or what lines are generating the
error.
I'm guessing that it's complaining about ret_buffer[index], but without
context we can't be sure.
Here is the code:
while (!endoffile)
{
cout<<setw(4)<<setfill('0')<<uppercase<<hex<<addr< <"0: ";
for (int index = 0; index <16; index++)
{
index2++;
if (index2 <= curr_buffer_size)
cout<<hex<<setw(2)<<setfill('0')<<(int)ret_buffer[index];
else
cout<<" ";
cout<<" ";
}//end for
cout<<setfill(' ');
//cout<< " ");
index2 = 0;
for (int index = 0; index < 16; index ++)
{
index2++;
if (index2 <= index)
{
if (ret_buffer[index] < 32 || ret_buffer[index] 126)
printf('.');
else
cout<<ret_buffer[index];
}//end if
}//end for

void output(unsigned char ret_buffer, int curr_buffer_size, bool&
endoffile)
{
int index2=0;
int addr=0;

while (!endoffile)
{
cout<<setw(4)<<setfill('0')<<uppercase<<hex<<addr< <"0: ";
for (int index = 0; index <16; index++)
{
index2++;
if (index2 <= curr_buffer_size)
133*
cout<<hex<<setw(2)<<setfill('0')<<(int)ret_buffer[index];
else
cout<<" ";
cout<<" ";
}//end for
cout<<setfill(' ');
//cout<< " ");
index2 = 0;
for (int index = 0; index < 16; index ++)
{
index2++;
if (index2 <= index)
{
146* if (ret_buffer[index] < 32 || ret_buffer[index] 126)
printf(".");
else
149* cout<<ret_buffer[index];
}//end if
}//end for
}

}//end output
Well,
unsigned char ret_buffer - you are passing a char and accessing an
array of char?
there are other compilation errors but I am sure you will be able to
get around them.

Gangs.

Feb 26 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mathieu Malaterre | last post by:
Hello, I have the following problem. I need to convert a unsigned char array into a string using only number (0-9) and '.'. The goal being to stored it on the minimal number of bytes. The...
4
by: ravinderthakur | last post by:
hi all experts, can anybody explain me the difference between the unsigned char and char in c/c++ langugage. specifically how does this affects the c library fucntion such as strcat,strtok...
1
by: cbachellam | last post by:
Hello, I am trying to call c++ dll function calls from C#. The c++ dll function takes in pointer to unsigned char array. Can anybody help me in what marshalling parameter value that i have to...
51
by: Pedro Graca | last post by:
I run into a strange warning (for me) today (I was trying to improve the score of the UVA #10018 Programming Challenge). $ gcc -W -Wall -std=c89 -pedantic -O2 10018-clc.c -o 10018-clc...
13
by: Eugene Rice | last post by:
I'm writing C code for an Atmel AVR micro controller. Because RAM space is extremely limited (about 500 bytes) I use char variables wherever I can. For example I use chars as array indices in...
4
by: Bobrick | last post by:
Hi. I'm in the process of making a GUI for a function someone else wrote, and i've come across a type i'm unfamiliar with, namely "std::vector<unsigned char>". I need to get the contents of this...
0
by: uche | last post by:
Please give me some feed back on this issue: Here is the complier error: hexdmp.cpp: In function `void output(unsigned char, int, bool&)': hexdmp.cpp:133: error: invalid types `unsigned char'...
30
by: Yevgen Muntyan | last post by:
Hey, Why is it legal to do union U {unsigned char u; int a;}; union U u; u.a = 1; u.u; I tried to find it in the standard, but I only found that
11
by: hamishd | last post by:
Is this possible? Sorry if this question isn't relevant here. actually, I'm really trying to convert a unsigned char * to an int
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.