Programming :: Using Of Arrays In Loops?

Sep 3, 2009

need to process files within multiple directories and transfer these to a remote server. What I had in mind was to use arrays for this; code pasted below (explains it better):

Code:
#set the arrays
array_A=( fileA* pathtodestA hostA passwordA )

[code]...

View 8 Replies


ADVERTISEMENT

Programming :: Using Loops In A Search?

Jan 21, 2010

Code:
Title=
echo -n "Title: "

[code]...

hey guys, im doing a simple search program and i came up with a problem. What i am trying to achieve is, if the search is false(means the book does exist) , the program will then ask the user to input the information again(title and author) and do a search again until there is no such book and then display a message saying he can input a new book in.i tried using a until loop, but it does not seem to work. some guidance on how the statement should be and where should it be placed?

View 4 Replies View Related

Programming :: Arrays In The C Programming Language Are Pointers To The First Element Of The Array?

Mar 27, 2010

I wonder why arrays in the C programming language are pointers to the first element of the array, not the first element of the array itself?

View 14 Replies View Related

Programming :: Bash Unset Array Loops GARBAGE?

Jun 27, 2011

Code:

#loop until there are no more files
while [ ${#files[@]} -gt 0 ]; do
for num in `seq 1 ${#files[@]}`; do
wurd=`tail -4 ${files[$num-1]}`

[code].....

Everything works.. but when it has to unset.. it breaks.. it doesnt give an error though.. it just jams the program.

View 7 Replies View Related

Programming :: Loops In Bash Shell Or Variable Math?

Oct 28, 2010

I am trying to map the coordinates of a grid.

Code:

R=7 # number of rows (lines)
C=6 # number of columns
X=200 # initial horizontal location
Y=100 # initial vertical location

[code]....

View 4 Replies View Related

Programming :: Adding Two Arrays?

Mar 1, 2010

I have a problem on a program,the problem take a very long time when i try to add two big arrays element by elementI know that matlab make adding vectors more faster than adding element by element but I don't know how!!!do any body knew how matlab make vectors operations more faster than element by element???I want to make my calculation more faster because the program is very big

View 8 Replies View Related

Programming :: Character Arrays In C?

Nov 3, 2010

I was reading Kernighan Ritchie book chapter 4 which deals with character pointers.I am not able to understand following different type of declarations

Code:
char aname[][15] = { "Illegal month", "Jan", "Feb", "Mar" };
char amessage[] = "now is the time";

[code]...

View 1 Replies View Related

Programming :: Can Diff Take Arrays As Input

Jun 19, 2010

Does diff not like arrays? How do achieve the following?

Code:

stuart@stuart:~/music transfer$ diff file1.txt file2.txt
1c1
< bonkers_in_phoenix.mp3

[code]....

View 14 Replies View Related

Programming :: Initializing Arrays In The Bash?

Mar 12, 2009

I'm making script for automated compiling of one program which would output builds optimized for many architectures. For clearancy, I do each build in it's own catalogue and list of builds with their respective catalogues would be stored as array. I'm using this guide as reference. It describes making array as naming a variable with additional brackets denoting it's position in array.

In my code, it looks exactly like this:

Code:

mtune[1]="build/mtune/athlon"
mtune[2]="build/mtune/athlon-4"
mtune[3]="build/mtune/athlon-mp"

[code]....

But upon invoking $mtune or any $mtune[x] variable, output is blank, like the variable(s) were never initialized. What am I doing wrong?

View 1 Replies View Related

Programming :: Printing 2 Arrays To 2 Columns?

Jun 16, 2010

I have a Perl script that has two arrays - they are related. I would like to print out the contents into two columns next to each other.

#!/usr/bin/perl
open(PINGFILE, </home/casper/pingdata.txt") or die " can not open file ";
my @totalfile=<PINGFILE>;
foreach $string(@totalfile) {
if ($string =~ m/(^1sping)(?=.*max))/) {
push(usecstring,"$string");

[Code]...

View 2 Replies View Related

Programming :: Structures And String Arrays, C?

Apr 18, 2011

I am working on a project that needs to use structures and I'm pretty sure string arrays. First I declare my structures and they must be exactly like this.

typedef struct
{
int hour;

[code]....

View 4 Replies View Related

Programming :: Create A Small Array Of 3x3 Arrays?

Jul 12, 2009

I'm trying to figure how to create an small array of 3x3 arrays such I can do

Code:

SUM1(i) = SUM1(i) + SUM2

where i goes from 1 to 8 and SUM2 is a 3x3 array.

View 2 Replies View Related

Programming :: Read Text File Using Arrays In C++?

Oct 19, 2010

a project using bluetooth to send data byte by byte to external devices buti'm not familiar using arrays to read file from another location before sending the data.If you could,do correct my codes.Here's my code,

void loop(){
char Msg[]={"Hello"};
char *start;

[code]...

View 2 Replies View Related

Programming :: Get Number Of Elements In A Hash Of Arrays?

Dec 10, 2008

I have something like this:

$arr_hash{'produce'}{'veggies'}[0] = Broccoli
$arr_hash{'produce'}{'veggies'}[1] = Cauliflower
$arr_hash{'produce'}{'veggies'}[2] = Carrots

[code]...

View 2 Replies View Related

Programming :: Perl - Pointers To Arrays From Hashes?

Feb 18, 2010

I'm trying to figure out how to code for this specific type of instance - I want to use a hash and have the key be a reference to an array, and not use the key in the standard way of it being a scalar. Basically, I have a large output that I need to process line by line, and rather have access to it as an array than a big block in a scalar. For the big block hash as a scalar I would do -

Code:
foreach $CONTROLLER (<CONTROLLER_LIST>) {
$ALL_DISKS{$CONTROLLER} = `ssh -n <commands>`;
}

Now I know I could take the scalar and split it to another array after the fact like -

Code:
@TEMP_HOLD = split (/s+/,$ALL_DISKS{$CONTROLLER});

How would I code it that I would have access to the key information as an array and not a scalar? I know it needs to be a pointer and we're going to have -> in there somewhere, but not sure how to approach it. Some of the documentaiton I've been reading about referencing I've found a little confusing so far, and trying to figure out how to use them in context of what I'm working on.

View 1 Replies View Related

Programming :: If Test Validation - Using Char Arrays

Jun 9, 2010

I'm writing a code to get the index of the last occurrence of a given substring in a string.

Code:
int StringHandler::lastIndexOf(string src, const string s) {
unsigned int lastIndex = string::npos;
if (src.find(s, 0) == string::npos) {
return -1; } else {
bool isLast = false; unsigned int i = 0; do {
lastIndex = src.find(s, i);
if (lastIndex != string::npos) { i = lastIndex + 1;
if (i == src.size()) { isLast = true;
} } else { isLast = true;
} } while (!isLast);
} return lastIndex;
}

My problem is: execution steps into an if with a false condition! Check the values of i and src.size() at the right panel. How could be possible for the program to run the highlighted statement? The if condition above is false! [URL]. I could use char arrays, for example, but this kind of false validation has happened to me more than once, I'm using G++ 4.5 with these flags: -O0 -g -Wall -c

View 3 Replies View Related

Programming :: PHP - Sorting Multi Dimensional Arrays By One Column

Mar 17, 2009

I just started programming in PHP so I haven't figured out how to do this yet, but I have a multi-dimensional array that I need to sort by one column. That's fine...but I need the sort to ignore case! Right now I have it sorted by 'name' (the other column is 'uid').

The problem is that by the default the sort is case-sensitive so the array looks like this:
Code:
Apple 4015
Banana 4011
Cherry 4045
avocado 4046

I want to be able to sort the the 'name' column in a case-insensitive manner so that the array actually looks like:
Code:
Apple 4015
avocado 4046
Banana 4011
Cherry 4045

How to accomplish this? Just FYI I'm not actually sorting the PLUs for fruits...but it was a simple example. I'm actually doing this for a Facebook application.

View 2 Replies View Related

Programming :: Bash: Combine Arrays & Delete Duplicates?

May 23, 2011

I would like to combine two arrays and delete duplicates that might occur. I tried to solve it like this:

Code:
combined=( "${results1[@]}" "${results2[@]}" )
printf "${combined[@]}" | sort -n | uniq
Example:
result1 (4 elements):

[Code]....

In my code printf seems to have a problem with elements that have the same letters but a space inbetween. For instance "new foo", "newfoo" are the same for printf

View 5 Replies View Related

Programming :: Bash Scripting Arrays And Indirect Referencing

Feb 23, 2010

I've got a situation. I'm having GNU bash version 3.00.16(1) on Solaris 10. I need to declare an array say arr1 which will be populated by an output of a command.

declare -a arr1
arr1=( $(/some/command) )

Supposing it will eventually (after executing the command) have element values as -

arr1[0]=1234
arr1[1]=5678
arr1[2]=7890

Now, I need to declare another set of arrays, one for each of the element values above - e.g.

declare -a arr1_1234
declare -a arr1_5678
declare -a arr1_7890

And I also need to populate elements of each of above 3 arrays with output of another command in a loop. So, these arrays will hold values something like -

arr1_1234[0]="abc"
arr1_1234[1]="def"
arr1_1234[2]="ghi"

arr1_5678[0]="jkl"
arr1_5678[1]="mno"
arr1_5678[2]="pqr"
arr1_7890[0]="tuv"
arr1_7890[1]="xyz"
arr1_7890[2]="aab"

I'm able to declare and populate arr1[*]. My question is how do I declare, populate and print the subsequent arrays and their elements?I am feeling rather thick to get this working.

View 7 Replies View Related

Programming :: Multi Dimensional Arrays In C Of Variable Size

Apr 15, 2010

I am curious if there is a way to describe and use variable sized multi-dimensional arrays in C using pointers. I mean, for 1-dimensional array e.g. I can use the following piece of code:

...
int i , N;
int *array;
scanf("%d", &N);
array = (int*) malloc(N*sizeof(int));
for (i=0; i<N; ++i) array[i] = i; // Assigning values to the array
for (i=0; i<N; ++i) printf("%d ", array[i]); // Printing the assigned values
free (array);
...

But what about the two dimensional array[N][M] ? I guess I have to use a double pointer e.g: int **array. But how exactly? Note that I use C90 and not C99.

View 2 Replies View Related

Programming :: Getting An Undefined Offset For The Associative Arrays [28-46] In Format

Dec 8, 2010

i'm getting an undefined offset for the associative arrays [28-46] in this format.

[Code]....

i have read that i can prevent the notices by doing the following, but it's not working for me

PHP Code:

[Code]....

View 5 Replies View Related

Programming :: Arrays In Awk - Take Some Data From A File - Ssh Log - And Print It To A Html Table

Feb 7, 2011

I have a problem with arrays in awk. What i want is to take some data from a file (ssh log) and print it to a html table. I have managed to print some stuff (user logged in and how many times they have logged in) What i want more is to take all the ip that each user logged in from and print it in a row next to the username and times (in the code i typed blabbla where i want the ip to be shown. How do you think i should approch that, multidimensional arrys maybe?

Code:

View 14 Replies View Related

Ubuntu :: Lucid Loops On Login

Jan 20, 2011

This is a mature Lucid installation on an desktop machine. After having to hard reset it after a lockup due to a misbehaving USB peripheral, startup and shutdown started behaving oddly (e.g. shutdown going to a login screen).

Now it is in a state where - on start up - after logging in successfully, the screen goes dark for a moment and then loops back to the login screen.

Have tried:
- booting in recovery mode,
- running dpkg repair (just an update of sudo)
- running in failsafeX - where problem is still present (so I assume the nvidia video drivers not to blame here)

Maybe relevant that:
- only one user account so cannot try logging in as another user,
- home folder is encrypted.
- hard disk has plenty of spare space.

View 5 Replies View Related

Ubuntu Multimedia :: Get Fruity Loops To Run Under Wine?

May 2, 2010

ive been trying to get fruity loops to run under wine and i havent been able to even get the program to show any signs of life.... it wont even start (or give any sign of starting) when i try to launch it.

View 1 Replies View Related

Ubuntu :: Windows 7 'loops' At Grub Loader

Jul 5, 2011

Basically the issue is that after I installed ubuntu 10.04 (on the same drive as Windows 7) I can no longer boot windows 7 from grub. When I select windows 7 in the grub boot menu it returns me to the boot menu.I looked through other posts who had similar problems, however, I wanted to post my own thread as I was unsure how to fix the problem based on information from other threads.

View 9 Replies View Related

Software :: Burning With K3b - Track 1 Loops Back

Jun 15, 2011

Using K3b 1.91.0 on Lucid in order to burn multitrack Video CDs.These burned fine before, and I made 5 working ones. Now having weird playback problem of burned VCDs first track looping back to the beginning instead of automatically advancing to later tracks. Same problem occurs on a variety of players including standalone DVD player. I can manually access the later tracks, but the later tracks don't continue automatically from track one.

The funny thing is that I'm using exactly the same mpeg VCD files that worked successfully before. I've got a feeling that the problem is some setting in K3b that I might have unintentionally changed, or else some nuance to how I'm adding the files to the project. I notice that when I add tracks to the project, a funny line always appears under a file name. Could that have anything to do with this problem? Also, would choosing "DAO" rather than "Auto" fix the problem? I'm tired of wasting the nice archival CD-Rs I bought!

View 3 Replies View Related

Networking :: Only Loops And Refreshes The Smbstatus Command?

Feb 18, 2010

for example i have wrote this so far: while [ 1 ]; do smbstatus;sleep 20; donethis only loops and refreshes the smbstatus command.but i want to continue loop.So when there is a new connection and locked files i want it to send to

View 1 Replies View Related

General :: Bash Script - Two For Loops With Array?

May 1, 2011

I am trying to execute a .c program of mine through bash... Problem is it takes two arguments (files) and am trying to use "for" loops to do it. I use the for loops to take the files (same number in both directories) and put them into arrays. I use the command "ls -1" in the "for loop" so they are sorted in such a way that they are in the same time and date order upon when the program is executed.

Here is the code:

Code:

for a in `ls -1 /analyses/data1/*_prt.txt`;
do echo $a;
done

[code]....

HOWEVER, $a in this case does not change with the loop. Thus, the program doesn't work. I then tried:

Code:

for a in `ls -1 /analyses/data1/*_prt.txt`;
for sfc in `ls -1 /analyses/data2/*_ht.txt`;
do
./plot_data $a $b >> log_file.log;
done

But that produces the error: syntax error near unexpected token `for'. As a "do" statement must come after the for loop call.

View 13 Replies View Related

Software :: Error - Email Loops Back To Myself

Aug 31, 2010

this is error message --> mail for apex.com.my loops back to myself

[Code]...

View 12 Replies View Related

Software :: Produce A Video That Loops Continuously?

Mar 15, 2010

I have an AVI which I produced on Blender in which a camera revolves around a model.

I want the camera to continuously circle the model over and over again.

I know I can do this in a GIF file format, but are there other formats that will do this?

What software can I use that would accomplish this?

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved