Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

array question

Status
Not open for further replies.

jo90

Programmer
Jun 19, 2002
30
GB
Hi,

If i assign the variable find, to the array;

arr[1]=find

should the following loop only print


for( i in arr)
print i


I can not get this to print the correct values; ie. the value from the variable find. How can I get this to work correctly?

Jo
 
on what you are workin on? shell, perl, awk, c ....
my be should be
for(a = 1; a< elements-of-array; print array[a++]);
vox clamantis in deserto.
 
your 'arr' will contain only ONE element - you keep reassigning the value of 'find' to same element of the array.

Change your assignment logic to something like [I don't know the exactl details of your logic]:

arr[++ind]=find

And then for printing:

for (iter in arr)
print arr[iter]; vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top