Wednesday 15 May 2019

c++ - lvalue required as increment operand error when using #define




Whats the problem with the code below, and why I'm getting this error?



#include 
#define A 1
using namespace std;

int main()
{
cout < return 0;

}

Answer



#define A 1


A is not valid c++ left value, so gave us "lvalue required as increment operand"



int A; 



is valid c++ left value and will work, also of other simple number type float, unsigned char etc


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...