Sponsored Content
Top Forums Programming Looping through multiple arrays in C. Post 303021254 by Azrael on Tuesday 7th of August 2018 10:58:17 AM
Old 08-07-2018
I did try that with pointers several different ways. Just tried it again and for the first time this compiled with no errors:

Code:
#include <stdio.h>
#include <stdlib.h>

int main() {

    int c;
    int *test;
    test = &c;

    int a [5] = {1,2,3,4,5};
    int b [5] = {6,7,8,9,10};

    for(c = 'a'; c <= 'b'; ++c) {
        for (int j = 0; j < 5; j++){
            printf("%d\n", test[j]);
        }
    }
}

The output is uniq, but wrong:

Code:
$ ./canloop
97
757351276
32767
0
4
98
757351276
32767
0
4

I guess I'm not dereferencing it right? Maybe I've just been up too long, but I'm open to more suggestions.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

multiple arrays through awk...

i am v new to awk, well unix as a whole really but im enjoying it alot... im trying to extract some data from a file, and parsing it into arrays, ive trawled for hours on the internet and cant find much when it comes to awk and arrays?? anyway, heres the file: tableA tableB tableC ... (2 Replies)
Discussion started by: newbeenie
2 Replies

2. Shell Programming and Scripting

Read multiple arrays in mysql

I have a database that include 5 tables, and they are related to each other through foreign key relations. The root is called colleges. There are multiple colleges, and each college has 1+ departments, each department has 1+ IT stuff, each IT stuff owns 1+ IP addresses. I have designed the database... (0 Replies)
Discussion started by: pinkgladiator
0 Replies

3. 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

4. Shell Programming and Scripting

multiple looping with case and funtion showing error, Please help

Hello All, I have code as follows :- while true do {opening a case1 statement} 1) {opening another case2 statement} {closing case 2} 2) Showing error for "2)" as Syntax error at line 59 : `)' is not expected. *) {closing case 1} ... (5 Replies)
Discussion started by: Renjesh
5 Replies

5. Shell Programming and Scripting

Looping for multiple directories

Hi experts, I am totally stuck with this. I run a looping "for" command for multiple directories, manually, I have done this : vfor dir in A B; do cp -p $dir/X.txt X-${dir}.txt done where A and B is directory name. However, I need to run for many directories. So I have tried this :... (7 Replies)
Discussion started by: guns
7 Replies

6. 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

7. Shell Programming and Scripting

Looping all subdierctories in multiple pipes

Hello friends, I want to run this code on every document in every sub-directory. tr -d '\n' < MulitpleInput.txt | awk '{gsub(/\. /,".\n");print}' | grep “\ I tried several looping techniques but couldn't get it to run in this example. Any ideas? Thank you (2 Replies)
Discussion started by: danbroz
2 Replies

8. Shell Programming and Scripting

Loop over multiple arrays

Hi All I need really really help with this :- I have two files ( File1 , File 2) both files are output of two different scripts. File1 usually has a list of names ( sometimes 3 names sometimes 5 sometimes more , depends about the output of the script) File2 usually has a list of numbers... (2 Replies)
Discussion started by: samsan
2 Replies

9. Shell Programming and Scripting

Multiple arrays in variable using for loop

Hi, I'm trying to get the number of files inside same kind of folders on each disks and assigning each values in to a variable named with same folder and disk name so that it'll be easy for me to identify each time.But somehow I'm not able to assign those values in that specific name variable... (1 Reply)
Discussion started by: ratheeshp
1 Replies

10. Programming

Looping an array of 2d arrays in C

Le sigh... Hopefully this will be the last time I have to ask for help on this topic. For a while now I've been working with a 1d array that holds 2d arrays. For reference you can view here. Now I'm just trying to loop through the elements with the following: #include <stdio.h> void... (3 Replies)
Discussion started by: Azrael
3 Replies
MYSQLND_QC_GET_QUERY_TRACE_LOG(3)					 1					 MYSQLND_QC_GET_QUERY_TRACE_LOG(3)

mysqlnd_qc_get_query_trace_log - Returns a backtrace for each query inspected by the query cache

SYNOPSIS
array mysqlnd_qc_get_query_trace_log (void ) DESCRIPTION
Returns a backtrace for each query inspected by the query cache. The collection of the backtrace is disabled by default. To collect the backtrace you have to set the PHP configuration directive mysqlnd_qc.collect_query_trace to 1 The maximum depth of the backtrace is limited to the depth set with the PHP configuration directive mysqlnd_qc.query_trace_bt_depth. PARAMETERS
This function has no parameters. RETURN VALUES
An array of query backtrace. Every list entry contains the query string, a backtrace and further detail information. +---------------------+---------------------------------------------------+ | Key | | | | | | | Description | | | | +---------------------+---------------------------------------------------+ | | | | query | | | | | | | Query string. | | | | | | | | origin | | | | | | | Code backtrace. | | | | | | | | run_time | | | | | | | Query run time in milliseconds. The collection | | | of all times and the necessary gettimeofday sys- | | | tem calls can be disabled by setting the PHP con- | | | figuration directive mysqlnd_qc.time_statistics | | | to 0 | | | | | | | | store_time | | | | | | | Query result set store time in milliseconds. The | | | collection of all times and the necessary get- | | | timeofday system calls can be disabled by setting | | | the PHP configuration directive | | | mysqlnd_qc.time_statistics to 0 | | | | | | | |eligible_for_caching | | | | | | | | | | TRUE if query is cacheable otherwise FALSE. | | | | | | | | no_table | | | | | | | | | | TRUE if the query has generated a result set and | | | at least one column from the result set has no | | | table name set in its metadata. This is usually | | | the case with queries which one probably do not | | | want to cache such as SELECT SLEEP(1). By default | | | any such query will not be added to the cache. | | | See also PHP configuration directive | | | mysqlnd_qc.cache_no_table. | | | | | | | | was_added | | | | | | | | | | TRUE if the query result has been put into the | | | cache, otherwise FALSE. | | | | | | | |was_already_in_cache | | | | | | | | | | TRUE if the query result would have been added to | | | the cache if it was not already in the cache | | | (cache hit). Otherwise FALSE. | | | | +---------------------+---------------------------------------------------+ EXAMPLES
Example #1 mysqlnd_qc_get_query_trace_log(3) example mysqlnd_qc.collect_query_trace=1 <?php /* Connect, create and populate test table */ $mysqli = new mysqli("host", "user", "password", "schema", "port", "socket"); $mysqli->query("DROP TABLE IF EXISTS test"); $mysqli->query("CREATE TABLE test(id INT)"); $mysqli->query("INSERT INTO test(id) VALUES(1), (2)"); /* not cached */ $res = $mysqli->query("SELECT id FROM test WHERE id = 1"); var_dump($res->fetch_assoc()); $res->free(); /* cache put */ $res = $mysqli->query("/*" . MYSQLND_QC_ENABLE_SWITCH . "*/" . "SELECT id FROM test WHERE id = 2"); var_dump($res->fetch_assoc()); $res->free(); /* cache hit */ $res = $mysqli->query("/*" . MYSQLND_QC_ENABLE_SWITCH . "*/" . "SELECT id FROM test WHERE id = 2"); var_dump($res->fetch_assoc()); $res->free(); var_dump(mysqlnd_qc_get_query_trace_log()); ?> The above examples will output: array(1) { ["id"]=> string(1) "1" } array(1) { ["id"]=> string(1) "2" } array(1) { ["id"]=> string(1) "2" } array(6) { [0]=> array(8) { ["query"]=> string(25) "DROP TABLE IF EXISTS test" ["origin"]=> string(102) "#0 qc.php(4): mysqli->query('DROP TABLE IF E...') #1 {main}" ["run_time"]=> int(0) ["store_time"]=> int(0) ["eligible_for_caching"]=> bool(false) ["no_table"]=> bool(false) ["was_added"]=> bool(false) ["was_already_in_cache"]=> bool(false) } [1]=> array(8) { ["query"]=> string(25) "CREATE TABLE test(id INT)" ["origin"]=> string(102) "#0 qc.php(5): mysqli->query('CREATE TABLE te...') #1 {main}" ["run_time"]=> int(0) ["store_time"]=> int(0) ["eligible_for_caching"]=> bool(false) ["no_table"]=> bool(false) ["was_added"]=> bool(false) ["was_already_in_cache"]=> bool(false) } [2]=> array(8) { ["query"]=> string(36) "INSERT INTO test(id) VALUES(1), (2)" ["origin"]=> string(102) "#0 qc.php(6): mysqli->query('INSERT INTO tes...') #1 {main}" ["run_time"]=> int(0) ["store_time"]=> int(0) ["eligible_for_caching"]=> bool(false) ["no_table"]=> bool(false) ["was_added"]=> bool(false) ["was_already_in_cache"]=> bool(false) } [3]=> array(8) { ["query"]=> string(32) "SELECT id FROM test WHERE id = 1" ["origin"]=> string(102) "#0 qc.php(9): mysqli->query('SELECT id FROM ...') #1 {main}" ["run_time"]=> int(0) ["store_time"]=> int(25) ["eligible_for_caching"]=> bool(false) ["no_table"]=> bool(false) ["was_added"]=> bool(false) ["was_already_in_cache"]=> bool(false) } [4]=> array(8) { ["query"]=> string(41) "/*qc=on*/SELECT id FROM test WHERE id = 2" ["origin"]=> string(103) "#0 qc.php(14): mysqli->query('/*qc=on*/SELECT...') #1 {main}" ["run_time"]=> int(311) ["store_time"]=> int(13) ["eligible_for_caching"]=> bool(true) ["no_table"]=> bool(false) ["was_added"]=> bool(true) ["was_already_in_cache"]=> bool(false) } [5]=> array(8) { ["query"]=> string(41) "/*qc=on*/SELECT id FROM test WHERE id = 2" ["origin"]=> string(103) "#0 qc.php(19): mysqli->query('/*qc=on*/SELECT...') #1 {main}" ["run_time"]=> int(13) ["store_time"]=> int(8) ["eligible_for_caching"]=> bool(true) ["no_table"]=> bool(false) ["was_added"]=> bool(false) ["was_already_in_cache"]=> bool(true) } } SEE ALSO
Runtime configuration, mysqlnd_qc.collect_query_trace, mysqlnd_qc.query_trace_bt_depth, mysqlnd_qc.time_statistics, mysqlnd_qc.cache_no_ta- ble, mysqlnd_qc_get_normalized_query_trace_log(3). PHP Documentation Group MYSQLND_QC_GET_QUERY_TRACE_LOG(3)
All times are GMT -4. The time now is 04:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy