What does int flag = 1 or flag = 0 means in C++ language? I have seen it in many programs but I don't know its use.
It just means you are declaring a variable called flag and giving it a value of 1 or 0. This will presumably be used elsewhere in the code to keep a track of the state of something. It is also probably boolean in nature.
The elaborate on DaveAmour's answer, you should know that C (the predecessor of C++) does not have a built-in boolean datatype, and until the C99 standard didn't have a standard defined one either. Thus, it has long been the convention in C to use
int variables as booleans, with 0 for false and any other value for true.
While C++ has always had a
bool type, a lot of C++ programmers who had started out in C never got into the habit of using it, and a lot of C programs which were converted to C++ were never changed to use it, either.
The variable name
flag (or some variation thereof) generally indicates that the variable is being used as a boolean value, and more specifically, a flag value, that is, one used to indicate a particular state or state change in the program. In file formats, an
int value may actually hold several packed flag fields, with the individual bits being treated as separate boolean values. However, in the context you are describing, it is more typical for it to hold just a single boolean value.
I'm new to python, for my project I need to send mail from python.. I'm getting the following error can someone please help me how to get out of it..
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for ...
Im trying to bind my custom vertical scrollbar to datagridview is this possible.. Please help Thnak you..
i am trying to create a library management system which is supposed to be used to store/keep infp for the library and the library members( book title, author, name and picture for borrower and other stuffs). The app has 6 buttons, delete, save, add,previsous,next, and upload( for upload ...