Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > sentinel control loops

Reply
Thread Tools

sentinel control loops

 
 
shan
Guest
Posts: n/a
 
      10-20-2005
Hi to everybody

here is my simple doubt

What is meant by sentinel control loops ?

 
Reply With Quote
 
 
 
 
Mistakenidentity18@gmail.com
Guest
Posts: n/a
 
      10-20-2005
Sentinel-controlled loops
When an unknown number of data items are to be processed, some way to
recognise the end of the data is needed.

One solution is to define a sentinel value
a unique value that indicates end-of-data
it cannot be a value that could occur as data

Code template:


sentinel : constant := ???;

loop
read (item);
exit when item = sentinel;

process the item;

end loop;


Example: add integers that the user enters, up to but not including -1
for end of data


tot := 0;
loop
PUT("Enter an integer (-1 to exit): ");
GET(j); SKIP_LINE;
exit when (j = -1);
tot := tot + j;
end loop;

-

MistakenIdentity

 
Reply With Quote
 
 
 
 
Mark McIntyre
Guest
Posts: n/a
 
      10-20-2005
On 20 Oct 2005 02:28:47 -0700, in comp.lang.c , "shan"
<> wrote:

>Hi to everybody
>
>here is my simple doubt


This isn't a doubt, its a question. For one thing, doubt is a verb...

>What is meant by sentinel control loops ?


loops where some sentinel value controls when you break out, or so I
would think

while(1)
{
int x = getchar();
if (x=='a') break;
}
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      10-21-2005
Mark McIntyre <> writes:
> On 20 Oct 2005 02:28:47 -0700, in comp.lang.c , "shan"
> <> wrote:
>>Hi to everybody
>>
>>here is my simple doubt

>
> This isn't a doubt, its a question. For one thing, doubt is a verb...


I have my doubts about that.

(Yes, doubt is a verb. It's also a noun. And yes, "question" is more
appropriate in this context.)

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
Ben Pfaff
Guest
Posts: n/a
 
      10-21-2005
Keith Thompson <kst-> writes:

> Mark McIntyre <> writes:
>> On 20 Oct 2005 02:28:47 -0700, in comp.lang.c , "shan"
>> <> wrote:
>>>Hi to everybody
>>>
>>>here is my simple doubt

>>
>> This isn't a doubt, its a question. For one thing, doubt is a verb...

>
> I have my doubts about that.
>
> (Yes, doubt is a verb. It's also a noun. And yes, "question" is more
> appropriate in this context.)


"doubt" is Indian English for "question". I've had discussions
with Indians at Stanford about this before.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      10-22-2005
On Fri, 21 Oct 2005 01:43:13 GMT, in comp.lang.c , Keith Thompson
<kst-> wrote:

>Mark McIntyre <> writes:
>> On 20 Oct 2005 02:28:47 -0700, in comp.lang.c , "shan"
>> <> wrote:
>>>Hi to everybody
>>>
>>>here is my simple doubt

>>
>> This isn't a doubt, its a question. For one thing, doubt is a verb...

>
>I have my doubts about that.


One could argue that the verb is "to have doubt" ...
>
>(Yes, doubt is a verb. It's also a noun.


True.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      10-22-2005
Mark McIntyre <> writes:
> On Fri, 21 Oct 2005 01:43:13 GMT, in comp.lang.c , Keith Thompson
> <kst-> wrote:
>>Mark McIntyre <> writes:
>>> On 20 Oct 2005 02:28:47 -0700, in comp.lang.c , "shan"
>>> <> wrote:
>>>>Hi to everybody
>>>>
>>>>here is my simple doubt
>>>
>>> This isn't a doubt, its a question. For one thing, doubt is a verb...

>>
>>I have my doubts about that.

>
> One could argue that the verb is "to have doubt" ...
>>
>>(Yes, doubt is a verb. It's also a noun.

>
> True.


Elsewhere in this thread, Ben Pfaff wrote:
] "doubt" is Indian English for "question". I've had discussions
] with Indians at Stanford about this before.
which is certainly consistent with the usage we've seen.

I suggest we accept the usage as a regional variant, just as we accept
both American and British spellings. Once you know the idiom, there's
no real ambiguity.

And it will give us more time to flame ppl 4 stpd abbrvs.

--
Keith Thompson (The_Other_Keith) kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
Kenny McCormack
Guest
Posts: n/a
 
      10-22-2005
In article <>,
Keith Thompson <kst-> wrote:
....
>Elsewhere in this thread, Ben Pfaff wrote:
>] "doubt" is Indian English for "question". I've had discussions
>] with Indians at Stanford about this before.
>which is certainly consistent with the usage we've seen.
>
>I suggest we accept the usage as a regional variant, just as we accept
>both American and British spellings. Once you know the idiom, there's
>no real ambiguity.


Note that, as verbs, "question" and "doubt" can be seen as synonyms.
So, maybe that's why some see them that way as nouns.

 
Reply With Quote
 
Emmanuel Delahaye
Guest
Posts: n/a
 
      10-22-2005
shan a écrit :
> Hi to everybody
>
> here is my simple doubt
>
> What is meant by sentinel control loops ?
>

A good standard example of sentinel is the trailing 0 of a C-string:

{
char s[] = "Hello world";
char *p = s;

while (*p != 0)
{
putchar (*p);
p++;
}
putchar ('\n');
}

--
C is a sharp tool
 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      10-23-2005
On Sat, 22 Oct 2005 17:01:55 GMT, in comp.lang.c , Keith Thompson
<kst-> wrote:

>
>I suggest we accept the usage as a regional variant, just as we accept
>both American and British spellings.


Alternatively, one could take the opportunity to correct what seems
mostly to be a misunderstanding. I work with many folks with
subcontinental origins, and few if any of them make this mistake. If
anything, it seems to be am americanism....

>And it will give us more time to flame ppl 4 stpd abbrvs.


oo r u kdin m8?
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DVD Verdict reviews: THE SENTINEL: THE COMPLETE FIRST SEASON and more! DVD Verdict DVD Video 0 04-26-2006 08:25 AM
Loops with loops using html-template Me Perl Misc 2 01-12-2006 05:07 PM
ConfigParser - add a stop sentinel? rzed Python 2 01-12-2005 07:17 PM
sentinel d.j. C++ 3 04-22-2004 05:19 AM
win xp serious error - sentinel DLL? hugh jass Computer Support 4 11-04-2003 04:38 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57