Sponsored Content
Top Forums Programming The C for() loop - A strange observation Post 302363275 by fpmurphy on Monday 19th of October 2009 11:56:47 PM
Old 10-20-2009
Not very strange. Your second example relates to a controlling expression which is always evaluated before each execution of the for loop. See ISO C99 6.8.5.3.

The statement for ( clause-1 ; expression-2 ; expression-3 ) statement
behaves as follows: The expression expression-2 is the controlling expression that is
evaluated before each execution of the loop body. The expression expression-3 is
evaluated as a void expression after each execution of the loop body. If clause-1 is a
declaration, the scope of any variables it declares is the remainder of the declaration and
the entire loop, including the other two expressions; it is reached in the order of execution
before the first evaluation of the controlling expression. If clause-1 is an expression, it is
evaluated as a void expression before the first evaluation of the controlling expression.
Both clause-1 and expression-3 can be omitted. An omitted expression-2 is replaced by a
nonzero constant.
 

9 More Discussions You Might Find Interesting

1. Solaris

Something strange...

Hi all, Thanks for any replies and for reading in advance. We have upgraded one of our database instances to 10g on a Solaris 8 box, anyhow the other day it started trying to ping loads of weird IP addresses that we don't use, since our systems all run on pretty similar IP's. It all behind... (0 Replies)
Discussion started by: B14speedfreak
0 Replies

2. What is on Your Mind?

observation...

That is one thing I find unusual about this forum, people post a list of program requirements and many people are happy to post complete solutions even though the person asking has shown no effort at all to solve the problem. Most other forums ( or the forum members anyway ) will not do that.... (9 Replies)
Discussion started by: KevinADC
9 Replies

3. Shell Programming and Scripting

Using variables created sequentially in a loop while still inside of the loop [bash]

I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends. As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

4. Shell Programming and Scripting

Null Handling in Until loop. . .loop won't stop

Hi Im running this script, which is supposed to find the max value build some tables and then stop running once all the tables are built. Thing is , it keeps assigning a null value to $h and then $g is null so it keep building tables i.e. testupdateNUL. How can I stop this? Here is what I have: ... (4 Replies)
Discussion started by: brandono66
4 Replies

5. Shell Programming and Scripting

BASH loop inside a loop question

Hi all Sorry for the basic question, but i am writing a shell script to get around a slightly flaky binary that ships with one of our servers. This particular utility randomly generates the correct information and could work first time or may work on the 12th or 100th attempt etc !.... (4 Replies)
Discussion started by: rethink
4 Replies

6. Shell Programming and Scripting

Strange exit of while loop

This code is used to check for duplicate ip and hostnames in an /etc/hosts file CENTRAL is path to /etc/hosts AWK =awk #check CENTRAL for duplicate ips or hostnames# grep -v "^#" $CENTRAL | $AWK '{ print $1, $2; }' | \ while read ip hostname do if... (5 Replies)
Discussion started by: trimike
5 Replies

7. Shell Programming and Scripting

Array Variable being Assigned Values in Loop, But Gone when Loop Completes???

Hello All, Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....? I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies

8. Shell Programming and Scripting

Reset while loop to loop same file multiple times

Hi, I want to read file multiple times. Right now i am using while loop but that is not working. ex. While read line do while read line2 do echo stmt1 #processing some data based on data., done < file2.txt done < file1.txt # This will have 10... (4 Replies)
Discussion started by: tmalik79
4 Replies

9. Shell Programming and Scripting

awk loop using array:wish to store array values from loop for use outside loop

Here's my code: awk -F '' 'NR==FNR { if (/time/ && $5>10) A=$2" "$3":"$4":"($5-01) else if (/time/ && $5<01) A=$2" "$3":"$4-01":"(59-$5) else if (/time/ && $5<=10) A=$2" "$3":"$4":0"($5-01) else if (/close/) { B=0 n1=n2; ... (2 Replies)
Discussion started by: klane
2 Replies
EVENTBASE(3)								 1							      EVENTBASE(3)

The EventBase class

INTRODUCTION
EventBase class represents libevent's event base structure. It holds a set of events and can poll to determine which events are active. Each event base has a method , or a backend that it uses to determine which events are ready. The recognized methods are: select , poll , epoll , kqueue , devpoll , evport and win32 . To configure event base to use, or avoid specific backend EventConfig class can be used. Warning Do NOT destroy the EventBase object as long as resources of the associated Event objects are not released. Otherwise, it will lead to unpredictable results! CLASS SYNOPSIS
EventBase final EventBase Constants o const integer$EventBase::LOOP_ONCE1 o const integer$EventBase::LOOP_NONBLOCK2 o const integer$EventBase::NOLOCK1 o const integer$EventBase::STARTUP_IOCP4 o const integer$EventBase::NO_CACHE_TIME8 o const integer$EventBase::EPOLL_USE_CHANGELIST16 Methods o public EventBase::__construct ([EventConfig $cfg]) o public void EventBase::dispatch (void ) o public bool EventBase::exit ([double $timeout]) o public void EventBase::free (void ) o public int EventBase::getFeatures (void ) o public string EventBase::getMethod ([EventConfig $cfg]) o public double EventBase::getTimeOfDayCached (void ) o public bool EventBase::gotExit (void ) o public bool EventBase::gotStop (void ) o public bool EventBase::loop ([int $flags]) o public bool EventBase::priorityInit (int $n_priorities) o public bool EventBase::reInit (void ) o public bool EventBase::stop (void ) PREDEFINED CONSTANTS
o EventBase::LOOP_ONCE - Flag used with EventBase::loop method which means: "block until libevent has an active event, then exit once all active events have had their callbacks run". o EventBase::LOOP_NONBLOCK - Flag used with EventBase::loop method which means: "do not block: see which events are ready now, run the callbacks of the highest-priority ones, then exit". o EventBase::NOLOCK - Configuration flag. Do not allocate a lock for the event base, even if we have locking set up". o EventBase::STARTUP_IOCP - Windows-only configuration flag. Enables the IOCP dispatcher at startup. o EventBase::NO_CACHE_TIME - Configuration flag. Instead of checking the current time every time the event loop is ready to run timeout callbacks, check after each timeout callback. o EventBase::EPOLL_USE_CHANGELIST - If we are using the epoll backend, this flag says that it is safe to use Libevent's internal change-list code to batch up adds and deletes in order to try to do as few syscalls as possible. Setting this flag can make code run faster, but it may trigger a Linux bug: it is not safe to use this flag if one has any fds cloned by dup(), or its variants. Doing so will produce strange and hard-to-diagnose bugs. This flag can also be activated by settnig the EVENT_EPOLL_USE_CHANGE- LIST environment variable. This flag has no effect if one winds up using a backend other than epoll . PHP Documentation Group EVENTBASE(3)
All times are GMT -4. The time now is 10:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy