Exforsys

Online Training

Different Approaches Needed

This is a discussion on Different Approaches Needed within the C and C++ forums, part of the Programming Talk category; What are the different ways a programmer of C programming language can pass arrays to functions? Kindly provide insight on ...


Go Back   Exforsys > Programming Talk > C and C++

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-26-2007, 04:43 PM
Member
 
Join Date: Apr 2006
Posts: 98
Angela is on a distinguished road
Thumbs up Different Approaches Needed

What are the different ways a programmer of C programming language can pass arrays to functions? Kindly provide insight on this concept
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-24-2007, 09:30 AM
Senior Member
 
Join Date: Apr 2006
Posts: 144
caradoc is on a distinguished road
One of the approach is you can pass the array to a function by value. These can done in three ways depending on your needs and usage. It is
Put the array in a struct.
Create a copy of the array in the calling function.
Create a copy of the array in the called function.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-24-2007, 09:41 AM
Senior Member
 
Join Date: Apr 2006
Posts: 141
Adrian is on a distinguished road
To avoid the approach of calling a function that requires a long list of arguments one can store the variables into an array, then pass a POINTER to the array to the function. The array isn't actually passed to the function but just the array's location in the memory. This is known as PASS BY REFERENCE. The name of an array references the array's location in the memory, its ADDRESS.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
urgent help needed saranyan USA Immigration 1 05-01-2007 10:05 AM
Command or Option needed Adrian DB2 1 04-22-2007 12:50 PM
Urgent help needed saranyan Microsoft .NET 1 04-03-2007 12:54 AM
Is Privilege Needed Angela Windows 1 03-13-2007 11:21 PM
Documents needed for Green Card Processing Vasu Immigration Help 1 10-11-2004 10:46 PM


All times are GMT -4. The time now is 12:35 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.