Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Help: stdin to multi-dimensional array Post 302507447 by unt_engn on Wednesday 23rd of March 2011 10:54:24 PM
Old 03-23-2011
Help: stdin to multi-dimensional array

I cant get out of this while loop at the beginning of my program. Just reading from stdin one char at a time and storing it into a multi-array. Need to fix it with in two hours.
Code:
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>

int main(int argc, char* argv[]){
char character;
char temp;
int i = 0;
int c = 0;
int j = 1;
int y = 0;
char line[20][20];
int count=0;

printf("Please enter your exec file and its arguments and pres ENTER.\n");        

do{
    temp = getchar();
            
        if(temp == ' '){
            line[count][i] = '\0';
            i = 0;    
            count++;
      }
            else{
                 line[count][i] = temp;    
                 i++;
                        
            }    
                          printf("%c", line[count][i-1]);            
    }while(temp != '\0');

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can there be multi-dimensional variable arrays in borne shell?

Hello - I've serached the web but can't find much on array script variables (except that C-shell variables are arrays!) I'm trying to form a 2-D string array: (this is what I want, but in java) String list = { {"one", "two"}, {"three"} }; I know this is a 1-D string array shell... (4 Replies)
Discussion started by: jparker
4 Replies

2. Programming

Multi-Dimensional Arrays

So, I'm fooling around with multi demtional arrays, and I made this in a short amount of time: #include <stdio.h> main(int argc, char *argv) { char blah = { {'a', 'b'}, {'b', 'a'} }; int i = 0; while (i < 2) { if (argv == blah) printf("%c\n", blah); i++; } } The goal... (3 Replies)
Discussion started by: Octal
3 Replies

3. Shell Programming and Scripting

Multi Dimensional array in KSH

Is there any way to use multi dim. array in KSH ? (1 Reply)
Discussion started by: sinpeak
1 Replies

4. Shell Programming and Scripting

Manipulating Pick multi dimensional data with awk.

Hi. I am reasonably new to awk, but have done quite a lot of unix scripting in the past. I have resolved the issues below with unix scripting but it runs like a dog. Moved to awk for speed and functionality but running up a big learning curve in a hurry, so hope there is some help here. I... (6 Replies)
Discussion started by: mike.strategis
6 Replies

5. Shell Programming and Scripting

PHP: how can I delete empty/NULL elements from a multi-dimensional array.

Hi all I have a file that i'm running and exec(cat ./dat) against..and putting its contents into any array, then doing an exploding the array into a multi-dimension array... The 15 multi-dimensional arrays have elements that are null/empty, I would like to remove/unset these elements and then... (2 Replies)
Discussion started by: zeekblack
2 Replies

6. Shell Programming and Scripting

PHP: Search Multi-Dimensional(nested) array and export values of currenly worked on array.

Hi All, I'm writing a nagios check that will see if our ldap servers are in sync... I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable so...eg...let take the single array... (1 Reply)
Discussion started by: zeekblack
1 Replies

7. Shell Programming and Scripting

Match elements in an AWK multi-dimensional array

Hello, I have two files in the following format; file1: A B C D E F G H I J K L file2: 1 2 3 4 5 6 7 8 9 10 11 12 I have read them both in to multi-dimensional arrays. I need a file that has column 2 of the first file printed out for each column 3 of the second file ie... ... (3 Replies)
Discussion started by: cold_Que
3 Replies

8. Shell Programming and Scripting

sorting multi dimensional array

Hi there, Can someone let me know how to sort the 2 dimensional array below by column 1 then by column 2? 22 55 2222 2230 33 66 44 58 222 240 11 25 22 60 33 45 output: 11 25 22 55 22 60 33 45 33 66 44 58 (6 Replies)
Discussion started by: phoeberunner
6 Replies

9. Shell Programming and Scripting

Multi Dimensional array

I have an array of names. Each one of the name, has a number represented to it. For example A has an ID 8, B has an ID 2. What I am after is a for loop that when the array is in position 1, a particular variable is set to the value of position 1 in array 2 declare -a arr=("A" "B" "C"... (6 Replies)
Discussion started by: nms
6 Replies

10. Shell Programming and Scripting

Multi Dimensional array in bash

Hi, I'm developing a script which contains a multi dimensional array, however for some reason the array is not iterating. When executing the script, services are listed as arguments from argument 2. Ex voice data sms. service=${@:2}; for services in $service do ... (2 Replies)
Discussion started by: nms
2 Replies
libcurl-multi(5)					      libcurl multi interface						  libcurl-multi(5)

NAME
libcurl-multi - how to use the multi interface DESCRIPTION
This is an overview on how to use the libcurl multi interface in your C programs. There are specific man pages for each function mentioned in here. There's also the libcurl-the-guide document for a complete tutorial to programming with libcurl and the libcurl(3) man page for an overview of the libcurl easy interface. All functions in the multi interface are prefixed with curl_multi. PLEASE NOTICE
The multi interface is a rather new member of the libcurl family. It has not yet been very widely used. It may still be a few more bugs lurking in there than we are used to. That said, it might also just work in every aspect you try it. Please report all bugs and oddities you see. OBJECTIVES
The multi interface introduces several new abilities that the easy interface refuses to offer. They are mainly: 1. Enable a "pull" interface. The application that uses libcurl decides where and when to ask libcurl to get/send data. 2. Enable multiple simultaneous transfers in the same thread without making it complicated for the application. 3. Enable the application to select() on its own file descriptors and curl's file descriptors simultaneous easily. ONE MULTI HANDLE MANY EASY HANDLES
To use the multi interface, you must first create a 'multi handle' with curl_multi_init. This handle is then used as input to all further curl_multi_* functions. Each single transfer is built up with an easy handle. You must create them, and setup the appropriate options for each easy handle, as out- lined in the libcurl(3) man page. When the easy handle is setup for a transfer, then instead of using curl_easy_perform (as when using the easy interface for transfers), you should instead add the easy handle to the multi handle using curl_easy_add_handl. The multi handle is sometimes referred to as a 'multi stack' because of the fact that it may hold a large amount of easy handles. Should you change your mind, the easy handle is again removed from the multi stack using curl_multi_remove_handle. Once removed from the multi handle, you can again use other easy interface functions like curl_easy_perform or whatever you think is necessary. Adding the easy handles to the multi handle does not start any transfer. Remember that one of the main ideas with this interface is to let your application drive. You drive the transfers by invoking curl_multi_perform. libcurl will then transfer data if there is anything avail- able to transfer. It'll use the callbacks and everything else you have setup in the individual easy handles. It'll transfer data on all current transfers in the multi stack that are ready to transfer anything. It may be all, it may be none. Your application can acquire knowledge from libcurl when it would like to get invoked to transfer data, so that you don't have to busy-loop and call that curl_multi_perform like a mad man! curl_multi_fdset offers an interface using which you can extract fd_sets from libcurl to use in select() or poll() calls in order to get to know when the transfers in the multi stack might need attention. This also makes it very easy for your program to wait for input on your own private file descriptors at the same time or perhaps timeout every now and then, should you want that. curl_multi_perform stores the number of still running transfers in one of its input arguments, and by reading that you can figure out when all the transfers in the multi handles are done. 'done' does not mean successful. One or more of the transfers may have failed. To get information about completed transfers, to figure out success or not and similar, curl_multi_info_read should be called. It can return a message about a current or previous transfer. Repeated invokes of the function get more messages until the message queue is empty. When all transfers in the multi stack are done, cleanup the multi handle with curl_multi_cleanup. Be careful and please note that you MUST invoke separate curl_easy_cleanup calls on every single easy handle to clean them up properly. libcurl 7.9.5 20 March 2001 libcurl-multi(5)
All times are GMT -4. The time now is 08:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy