Error 2 Error C2107 Illegal Index Indirection Not Allowed
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up accessing the array inside array of structures up vote 1 down vote favorite I have a structure as follows struct a { char* ap; char* inputs[10]; int e; }; then I have created an array of this structure like struct a list [100]; now i want to fille the array inputs[10] and for that I am using the syntax to access the first location : ip=0; inp=0; list[ip].inputs[inp] but I am gettin the error "error C2107: illegal index, indirection not allowed" on compiling the code please suggest how to access the array location inside array of structure. regards priya c visual-studio-2010 share|improve this question edited Apr 5 '13 at 7:46 AurA 6,75322349 asked Apr 5 '13 at 6:20 priya 347315 Have you tried with the pointer.. I mean *list and then list[ip]->inputs[inp]..?? –Hiren Pandya Apr 5 '13 at 6:22 yes I have tried but still the same error –priya Apr 5 '13 at 6:27 1 Works here without error. Maybe an MSVC bug? –user529758 Apr 5 '13 at 6:31 add a comment| 3 Answers 3 active oldest votes up vote 1 down vote accepted Here you use array of character pointer in your structure. So Initially you allocate memory for you structure by creation list of 100. I think you didn't create memory for you array of character pointer. You have to create memory for each of character pointer. So I suggest example code. #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Assigning value into unordered_map pointer after creating a instance of it up vote 0 down vote favorite I'm using a unordered map pointer because of C++/Cli on Visual Studio 2008 http://stackoverflow.com/questions/15827205/accessing-the-array-inside-array-of-structures (Using Windows Forms Application), but I can't assign a value to it, it throws an error, as my code example is showing //... public ref class Login: public System::Windows::Forms::Form { public: unordered_map< std::string, std::string >* Accounts; Test(void) { this->Accounts = new unordered_map
problem with this. 1 Programming Boards C++ Programming Operator[] error Getting started with C or C++ | C Tutorial | C++ Tutorial | C and C++ FAQ | Get a compiler | Fixes for common problems Thread: Operator[] error Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 04-04-2006 #1 cboard_member View Profile View Forum Posts Supermassive black hole Join Date Jul 2005 Posts 1,709 Operator[] error I've just ran into a problem with this: Code: #include "stdafx.h" using namespace std; class HashTable { int data[100]; public: HashTable(); ~HashTable(); int operator[](char *rhs); }; HashTable::HashTable() { for (int i = 0; i < 100; i++) data[i] = 0; } HashTable::~HashTable() { } // operator[] int HashTable::operator[](char *rhs) { int hash = 0; int i = 0; // construct a hash from the string for (; *(rhs + i) != 0; i++) hash += static_cast
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int getlargest(int &list, int count) //this function goes through the data stored in the dynamic array //finds the largest http://www.cplusplus.com/forum/beginner/41131/ number in the array //and returns that number to printstuff(int,int) { int *num; num = new int; *num = 0; for(int *i=0;*i
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int getlargest(int *list, int count) //this function goes through the data stored in the dynamic array //finds the largest number in the array //and returns that number to printstuff(int,int) { int *num; num = new int; *num = 0; for(int *i= new int(0);*i
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int getlargest(int *list, int