Chat on IRC |
C++ newbie question #
Posted by diegoeskryptic [send private reply] at April 08, 2002, 12:13:47 PM
today in class i learned a new term called SENTINEL value. My teacher told me not to worry about it much. However, im still interested in knowing just exactly what it is, how it is used, why it is use..... thanx guys...
Posted by metamorphic [send private reply] at April 08, 2002, 12:34:32 PM
i dont know exaccly what a sentinal value is, but it sounds like a flag. A flag is normally a boolean value (true or false) that represents whether something has happened or not. for example in on of my programs, one function takes a boolean value as a paramiter to check if an error occured. if this 'flag' value is true then an error occured.
Although like i siad, not too sure what a sentinal val is Marc
Posted by manoj [send private reply] at April 08, 2002, 12:47:40 PM
Well diego, I've heard that sentinental thing as a variable
to be compared in the condition in loops. U can take the verbal meaning. If its something different then I don't know. But I think ur teacher's talking about the same thing.
Posted by Psion [send private reply] at April 08, 2002, 01:35:32 PM
The term refers to a special input value that a user enters to terminate an input loop.
Posted by CodeRed [send private reply] at April 08, 2002, 02:26:31 PM
commonly a -1
Posted by diegoeskryptic [send private reply] at April 08, 2002, 03:07:08 PM
Hey psion.... is it like the break statement that is used in switch statements?
Posted by RedX [send private reply] at April 08, 2002, 04:59:31 PM
bool done = false; while (!done) { // do some intresting stuff that might set done to true } so 'done' is called a sentinel? RedX
Posted by Psion [send private reply] at April 08, 2002, 05:14:59 PM
No. It's a completely irrelevant issue that only shows up in types of programming mostly limited to introductory programming classes where you do purposely simple things, but this is an example:
int a = 0; while (a != 875) { printf("Enter the value. "); scanf("%d", &a); }
Register as a new user | ||||||||||