473,324 Members | 2,313 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,324 software developers and data experts.

Having trouble calling an array!

Trying to pass a multi-dimensional array but it won't work. Any suggestions?

const int SIZE = 3;
int row;
int col;
int PBUF[3][3];
int getPBUF(int *PBUF);

int main()
{
int PBUF[SIZE];

getPBUF(PBUF);
}

int getPBUF(int *PBUF)
{
cout << "Enter 3 rows of 3 integers each:\n";
for (row = 0; row < SIZE; row++)
for (col = 0; col < SIZE; col++)
cin >> PBUF[row][col]; //this is where "error C2109: subscript requires array or pointer type"
}
Apr 8 '08 #1
2 1163
gpraghuram
1,275 Expert 1GB
Trying to pass a multi-dimensional array but it won't work. Any suggestions?

const int SIZE = 3;
int row;
int col;
int PBUF[3][3];
int getPBUF(int *PBUF);

int main()
{
int PBUF[SIZE];

getPBUF(PBUF);
}

int getPBUF(int *PBUF)
{
cout << "Enter 3 rows of 3 integers each:\n";
for (row = 0; row < SIZE; row++)
for (col = 0; col < SIZE; col++)
cin >> PBUF[row][col]; //this is where "error C2109: subscript requires array or pointer type"
}

You have declared PBUF both globally and locally.
When u pass that as argument only that will be used inside the function.
The paramter is of single dimension and u are trying to use it asa 2 dimension array.

Thanks
Raghuram
Apr 8 '08 #2
weaknessforcats
9,208 Expert Mod 8TB
You might read this article: http://bytes.com/forum/thread772412.html.
Apr 8 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: | last post by:
I fail to understand why that the memory allocated in the void create(int **matrix) does not remain. I passed the address of matrix so shouldn't it still have the allocated memory when it returns...
1
by: Harlin Seritt | last post by:
from utilities import * from extractor import * import time import os print 'Running AgentPing at '+time.asctime() confFile = '../conf/AgentPing/AgentPing.conf' ex = extractor(confFile)
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
3
by: Michael | last post by:
Hi all, I'm having trouble PInvoking a TCHAR within a struct. I'll paste the specific struct's API definition below. I've tried so many numerous variations. The main Win32 error I get is...
5
by: tkondal | last post by:
Hi all. I just started looking at Python's ctypes lib and I am having trouble using it for a function. For starters, here's my Python code: from ctypes import*; myStringDLL=...
0
grassh0pp3r
by: grassh0pp3r | last post by:
Hello, I'm trying to make a very simple comments page on my site using PHP and am having problems somewhere. I am very new to PHP. I was able to create one that works with comments appended, but...
5
by: polas | last post by:
Afternoon everyone. I am having some trouble and thought a few of you might be able to help me... I have a simple function to copy the contents of one array into another - the arguments to the...
24
by: GesterX | last post by:
First of all I'm new to this site but it certainly looks like a place that i will be visiting more often! Onto my problem. I am creating a Hotel Bussiness project in java using BlueJ The...
1
by: runningsnake24 | last post by:
We are writing a program to check that a filled in Sudoku puzzle is solved correctly. We are required to use the Iterator and Iterable interfaces. The program uses a Cell class to represent each...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.