Sunday, August 2, 2009

What do these mean in C programming, !=0, ==0, ==1?

I'm new to programming and can't find an internet resource that explains these basic "functions".





Everything skips to strcmp's and sprints! They assume you know these symbols.





(...==0) (...!=0) (....==1)

What do these mean in C programming, !=0, ==0, ==1?
Try the link below.





BTW, the symbols are called operators. A Google search for 'basic C operators' returns many valid web pages with the answer you seek. The link below is just one of those.
Reply:You may want to keep this link handy or just print it out.





One thing I always found to be a problem is


if(a=b)


if(a==b)





The first if is not a test it is an assignment and will always return true.


The second if is a test for equality. This is a typical mistake that is not just made by beginners. However knowing what to look for can help to find the problem.





Good luck.
Reply:!=0 Your variable is NOT zero





== your comparing your variable to zero or 1





single = then you would be assigning the variable to 0 or 1


whereas your double == is a comparison and returns TRUE or FALSE
Reply:==0 compares the criteria to see if the value is equal to 0


!=0 compares to see if the value is NOT equal to 0


No comments:

Post a Comment