if statement | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

8th Nov 2022, 12:00 PM
Humza Ali
Humza Ali - avatar
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").
8th Nov 2022, 2:43 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 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.
8th Nov 2022, 2:43 PM
Brian
Brian - avatar
+ 1
Thanks guys!
8th Nov 2022, 4:01 PM
Humza Ali
Humza Ali - avatar