0
if statement
I am learning c++. I have understand the basic C++ if statements but I have seen one recently which contains comma. I understand that we can give different type of parameters but I am not sure why is it used below. struct stat sb; if (lstat(filepath.c_str(), &sb) == -1) return false
3 Answers
+ 2
The comma is not part of the if-statement. The if statement only checks the equally of a function return value and the literal value negative one. If you want to know what lstat does and the error codes it returns, you may want to refer to the man pages ("man lstat").
+ 1
It is calling a function named lstat() that takes two arguments - a file path and a structure pointer. The arguments are separated by a comma.
+ 1
Thanks guys!