Sponsored Content
Top Forums Programming Looping through multiple arrays in C. Post 303021292 by Corona688 on Tuesday 7th of August 2018 04:56:26 PM
Old 08-07-2018
That it compiled without errors only means your program is correct grammatically, the same way "my hovercraft is full of eels" will pass a grammar check but not help Belgians communicate with foreigners. Your program does not do what you think it does.

Code:
for(c = 'a'; c <= 'b'; ++c)

'a' and 'b' are the ASCII integers 91 and 92, respectively. They are not the arrays a and b and cannot be used to retrieve those variables.

How about this?

Code:
#include <stdio.h>

int main(int argc, char *argv[])
{
        int a [5] = {1,2,3,4,5};
        int b [5] = {6,7,8,9,10};
        int *c[]={a, b}; // c[0] is effectively a, c[1] is effectively b

        int n, m;

        for(n=0; n<1; n++)
        {
                for(m=0; m<5; m++)
                {
                        printf("Array %d[%d] = %d\n", n, m, c[n][m]);
                }
        }
}


Last edited by Corona688; 08-07-2018 at 06:19 PM.. Reason: fixed several errors
These 3 Users Gave Thanks to Corona688 For This Post:
 

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
VOIKKOGC(1)						      General Commands Manual						       VOIKKOGC(1)

NAME
voikkogc - test program for Voikko grammar checker SYNOPSIS
voikkogc [options] DESCRIPTION
voikkogc is a test program for grammar checking functionality in libvoikko, library of Finnish language tools. It reads sentences or para- graphs from stdin (one per line) and print the results to stdout. The results are structures containing information about grammar errors found in the input paragraph. OPTIONS
--tokenize Instead of looking for grammar errors, split input into tokens. The tokens are prefixed by type: "W" is a word, "P" is punctuation, "S" is whitespace, "U" is unknown and "E" is a prefix for error messages. --split-sentences Instead of looking for grammar errors, split input into sentences. The sentences are prefixed by type: "B" means that end of sen- tence is a probably correct, "P" means that end of sentence is a possibly correct (but probably this and the next identified sen- tence should be joined) and "E" means that sentence ends at the end of input. -n Prefix all grammar checker messages with line number of input data. accept_titles=n accept_unfinished_paragraphs=n accept_bulleted_lists=n Set the value of the specified boolean option. explanation_language=langcode Print human readable error explanation in the specified language. BUGS
Human readable error explanations are printed in UTF-8 regardless of current locale settings. SEE ALSO
voikkospell for common options of different Voikko test tools. AUTHOR
voikkogc and this manual page were written by Harri Pitkanen (hatapitk@iki.fi). 2010-05-06 VOIKKOGC(1)
All times are GMT -4. The time now is 05:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy