Sponsored Content
Top Forums Programming Looping an array of 2d arrays in C Post 303023469 by Corona688 on Monday 17th of September 2018 03:15:09 PM
Old 09-17-2018
You have to follow the method I showed to-the-letter. (*arr[a][b])[c] is not the same as (*arr)[a][b][c].

Code:
void arrbyptr(int (*ptr[2][2])[2]) {
        int result, i, j, k;
    for ( i = 0; i < 2; ++i ){
        for ( j = 0; j < 2; ++j ){
            for ( k = 0; k < 2; ++k ){
                result = (*ptr)[i][j][k];
                printf("%d\n", result);
            }
        }
    }
}

These 2 Users Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl question - looping through an array of hashrefs

I have an array of hashrefs that look like the following: my @LAYOUT = ( {SQL_1 => "select count (*) FROM prospect WHERE PROCESS_DATE = To_date('INSERT_DATE_HERE', 'mm/dd/yyyy') and tiff_filename is not null ... (2 Replies)
Discussion started by: kregh99
2 Replies

2. Shell Programming and Scripting

KSH script not looping through array

Hi All, I'm trying to get a script to loop through an array. The array is basically a list of .zip files. I'd like the script to loop through and unzip the zip files contained in the zip file list. When I run the script, it unzip the first zip file correctly, and then stops Any thoughts? Here's... (2 Replies)
Discussion started by: kelldan
2 Replies

3. Shell Programming and Scripting

Perl array of arrays

Hi, I am trying to assign an array as a value to one of the array element, I mean I have an array @KS and array @kr. I want array @KS to hold @kr as an element. So I am doin this $KS=@kr; But the value stored is number of elements in the @kr array. Can... (2 Replies)
Discussion started by: eamani_sun
2 Replies

4. UNIX for Dummies Questions & Answers

Help in Array looping and creating multiple lines

hi Gurus, I'm a newbie in scripting please check my script if this is correct. I think there's something wrong with it but I;m not sure. I'm trying to create multiple lines using awk from external xml files but i want to add additonal info in the data manually Since i don't knwo how to... (0 Replies)
Discussion started by: sexyTrojan
0 Replies

5. Shell Programming and Scripting

Looping through arrays

i just started learning arrays and found this example on the net: for (( i = 0 ; i < ${#names} ; i++ )) do echo ${names} done However, even though I can echo ${#names} I am unable to get the increment to work. I have tried eliminating spaces and changing brackets and nothing seems... (4 Replies)
Discussion started by: newbie2010
4 Replies

6. UNIX for Dummies Questions & Answers

Looping through the contents of array for output name

Hi all, I am trying to loop through the string contents of an array, to add it during the saving of the output files. I am trying this code to print each column and save it to unique file name, but it doesn't work. Thanks for any help. fnam=(japan usa uk) alldata.dat contained sample data... (1 Reply)
Discussion started by: ida1215
1 Replies

7. Shell Programming and Scripting

Bash arrays: rebin/interpolate smaller array to large array

hello, i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N. for case 1, I want to stretch N to fit M arrayHuge H = (... (2 Replies)
Discussion started by: f77hack
2 Replies

8. Programming

Looping through multiple arrays in C.

Not sure if this is possible, but I've tried this about a thousand ways now. I am making something with a lot of arrays. I thought I could put the array names into a separate array and then loop through them to call all of their elements. This is the best I've got so far: #include <stdio.h>... (4 Replies)
Discussion started by: Azrael
4 Replies

9. Programming

Making an array of 2D arrays in C

I hate I'm asking for help again. Unfortunately it seems there just aren't any links I can find on making an array that holds a bunch of two dimensional arrays. Maybe my google-fu is lacking. Basically I have a header file like this: #define MATRIX 10 int white_l1; int white_l2; int... (2 Replies)
Discussion started by: Azrael
2 Replies

10. Programming

Calling an array of arrays in C.

Corona688 was great in helping me learn how to create arrays that hold other two dimensional array here. Unfortunately I didn't think ask about how to implement or call them. Basically, I'm trying to call an array of two-dimensional arrays like this: declaration: int (*side_one) = { { white_l1,... (6 Replies)
Discussion started by: Azrael
6 Replies
PG_FETCH_ALL(3) 														   PG_FETCH_ALL(3)

pg_fetch_all - Fetches all rows from a result as an array

SYNOPSIS
array pg_fetch_all (resource $result) DESCRIPTION
pg_fetch_all(3) returns an array that contains all rows (records) in the result resource. Note This function sets NULL fields to the PHP NULL value. PARAMETERS
o $result - PostgreSQL query result resource, returned by pg_query(3), pg_query_params(3) or pg_execute(3) (among others). RETURN VALUES
An array with all rows in the result. Each row is an array of field values indexed by field name. FALSE is returned if there are no rows in the result, or on any other error. EXAMPLES
Example #1 PostgreSQL fetch all <?php $conn = pg_pconnect("dbname=publisher"); if (!$conn) { echo "An error occurred. "; exit; } $result = pg_query($conn, "SELECT * FROM authors"); if (!$result) { echo "An error occurred. "; exit; } $arr = pg_fetch_all($result); print_r($arr); ?> The above example will output something similar to: Array ( [0] => Array ( [id] => 1 [name] => Fred ) [1] => Array ( [id] => 2 [name] => Bob ) ) SEE ALSO
pg_fetch_row(3), pg_fetch_array(3), pg_fetch_object(3), pg_fetch_result(3). PHP Documentation Group PG_FETCH_ALL(3)
All times are GMT -4. The time now is 06:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy