473,414 Members | 1,757 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,414 software developers and data experts.

Array pointer and Array are the same?

Will is affect the result if I pass Array Pointer as a parameter to a
function compare to Array as a parameter?
For example,
BYTE buffer[1024]
a.) function(&buffer)
b.) function(buffer)
Is it any differences between (a) and (b)?
Thanks in advance.

Kenny
Nov 17 '05 #1
3 927
Hello Kenny,
Will is affect the result if I pass Array Pointer as a parameter to a
function compare to Array as a parameter?
For example,
BYTE buffer[1024]
a.) function(&buffer)
b.) function(buffer)
Is it any differences between (a) and (b)?


buffer == &buffer == &buffer[0]
Nov 17 '05 #2
a. function prototype (it seems) does not allow. &buffer is
BYTE(*)[1024].
This means, pointer to a BYTE array with size of 1024 elements. But
function, as far as I can understand, expects either BYTE[], or a
BYTE*.

the function prototype that would accept your example should be

int f(BYTE (*pArr)[1024[);
b. function prototype is either BYTE[] or BYTE* (I guess, may be a void
pointer, or something else that accepts any of BYTE[] or BYTE*). In
that case, "b" should compile, but "a" should give an error.

if your intent is to write something that can accept both arrays and
arrays of arrays, try to use templates.

Ismail Pazarbasi

Nov 17 '05 #3
thanks..
got it... :)

"ismailp" <pa*******@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
a. function prototype (it seems) does not allow. &buffer is
BYTE(*)[1024].
This means, pointer to a BYTE array with size of 1024 elements. But
function, as far as I can understand, expects either BYTE[], or a
BYTE*.

the function prototype that would accept your example should be

int f(BYTE (*pArr)[1024[);
b. function prototype is either BYTE[] or BYTE* (I guess, may be a void
pointer, or something else that accepts any of BYTE[] or BYTE*). In
that case, "b" should compile, but "a" should give an error.

if your intent is to write something that can accept both arrays and
arrays of arrays, try to use templates.

Ismail Pazarbasi

Nov 17 '05 #4

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

Similar topics

58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
14
by: dam_fool_2003 | last post by:
Friends, cannot we malloc a array? So, I tried the following code: int main(void) { unsigned int y={1,3,6},i,j; for(i=0;i<3;i++) printf("before =%d\n",y); *y = 7; /* 1*/
11
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
8
by: Sam | last post by:
I have a situation occuring in my code and I just can't see to figure out why I have an structure called employee that will put all of the employee id's into a char array set to 10 struct...
12
by: gcary | last post by:
I am having trouble figuring out how to declare a pointer to an array of structures and initializing the pointer with a value. I've looked at older posts in this group, and tried a solution that...
26
by: aruna.mysore | last post by:
Hi all, I have a specific problem passing a function pointer array as a parameter to a function. I am trying to use a function which takes a function pointer array as an argument. I am too sure...
152
by: vippstar | last post by:
The subject might be misleading. Regardless, is this code valid: #include <stdio.h> void f(double *p, size_t size) { while(size--) printf("%f\n", *p++); } int main(void) { double array = { {...
33
by: Adam Chapman | last post by:
Hi, Im trying to migrate from programming in Matlab over to C. Im trying to make a simple function to multiply one matrix by the other. I've realised that C can't determine the size of a 2d...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.