•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 402,372 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,123 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1051 | Replies: 3 | Solved
![]() |
•
•
Join Date: Apr 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Hey, I'm writting a program in C that is supposed to be a simple connect four game. I ran into problems when I tried to assign my array connects to a set value. The compiler gave me the error, Invalid indirection. Heres a little bit of the code where the problem is.
I tried several different ways like:
and I'm using Borland C++ builder 5.
c Syntax (Toggle Plain Text)
// ask user how big of a board is wanted printf("\n\nSelect game board size."); printf("\nEnter number of rows. (min 4, max 9): "); scanf("%d", &num_rows); // valid entry check for rows while((num_rows < 4) || (num_rows > 9)) { printf("\n\nInvalid entry, Please re-enter row size: "); scanf("%d", &num_rows); } printf("\nEnter number of columns. (min 4, max 9): "); scanf("%d", &num_cols); // valid entry check for columns while((num_cols < 4) || (num_cols > 9)) { printf("\n\nInvalid entry, Please re-enter row size: "); scanf("%d", &num_cols); } // memory allocation based on user defined board size ptr2d = (char *)malloc(sizeof(char)*num_cols*num_rows); board_ptr = ptr2d; // clean allocated memory and assign a generic filler for (j = 0; j <= num_cols; j++) for (i = 0; i <= num_rows; i++) *board_ptr[i][j] = "*"; //<------problem here
I tried several different ways like:
c Syntax (Toggle Plain Text)
board_ptr[i][j] ="*" *(board_ptr[i][j]) ="*" (*board_ptr[i][j]) ="*"
and I'm using Borland C++ builder 5.
Last edited by WolfPack : Apr 2nd, 2007 at 6:28 pm. Reason: [CODE][/CODE] tags
Apparently
http://www.daniweb.com/techtalkforum...cement8-3.html
Isn't in a big enough font, all the noobs keep missing the point.
http://www.daniweb.com/techtalkforum...cement8-3.html
Isn't in a big enough font, all the noobs keep missing the point.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Problem with memory allocation =( (C)
- Static and Dynamic Memory Allocations...Advan's & Disadvan's??? (Computer Science and Software Design)
- regarding dynamic memory allocation (C)
- memory allocation ptr to array? how? (C)
- Dynamic memory allocation homework (C++)
Other Threads in the C++ Forum
- Previous Thread: Error C2660 Function does not take 1 argument
- Next Thread: Learning "C"



Linear Mode