pr*****@polaris .co.in wrote:
Eric Sosman wrote:
pr*****@polar is.co.in wrote:
I have a program that will read as follows
#define MS(x) memset(x.arr,'\ 0',sizeof(x.arr *))
void memset_var()
{
int cnt =0;
for (cnt=0;cnt<ARR_ SIZE;cnt++)
{
MS(v_array_temp[cnt]);
}
}
How do i avoid loop and is there any short cut or easier method to
clear the array without using loop
You haven't given enough information. How is
`v_array_temp ' declared?
--
Eric Sosman
es*****@acm-dot-org.invalid
[snip]
,-- replaced by content of other reply ---
| VARCHAR v_array_temp[ARR_SIZE][11];
|
| This is Pro*C program to clear the array and fetch records and then
| manipulate and then do bulk update. after that i have to use
| memset_var() to clear the array and fetch another set of records.
`----
this is Pro*C program that declare a cursor and fetch the column value
into v_array_temp. if ARR_SIZE is 4000 then 4000 records are fetched
into this variable and we manipulate the same and use bulk update to
update the new values from that v_array_temp variable. loop continues
after the update by calling memset_var() to clear the array and fetch
another 4000 records to do the process of fetching and updating till
End of Records in the table.
Hope this information is clear. please help me to avoid loop to clear
the variable. please let me know is there any shortcut or single line
statement to clear the VARCHAR array.
The problem is that you still do not tell enough about v_array_temp:
We need the definition of VARCHAR and recursively everything that
is not a standard C type.
Apart from that, the above declaration of v_array_temp will not
work in conjunction with MS as v_array_tmp[cnt].arr does not make
sense for an array ARR_SIZE of an array 11 of VARCHAR.
If VARCHAR is some kind of structure type intended as wrapper
for strings you _might_ get lucky and can memset() everything
to zero.
Just give us enough information :-)
BTW: Another strategy to have less function calls for an array
of objects you cannot initialise via memset() is using memcpy()
in a loop and doubling the number of copied objects. However,
this is potentially error prone compaired to a plain loop
and has a certain overhead, so it may be less efficient due to
this overhead. Another thing is that the compiler can easier
find a suitable optimisation strategy (maybe even the above)
if you give it a plain loop.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.