From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/C/SYNTAX/got_ya.html | 80 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 reference/C/SYNTAX/got_ya.html (limited to 'reference/C/SYNTAX/got_ya.html') diff --git a/reference/C/SYNTAX/got_ya.html b/reference/C/SYNTAX/got_ya.html new file mode 100644 index 0000000..4781430 --- /dev/null +++ b/reference/C/SYNTAX/got_ya.html @@ -0,0 +1,80 @@ +Got Ya + + + + +
+
+

Got Ya

+
+
+ + + +
+An error which almost every C programmer has made is shown below: +
+	main()
+	{
+	   int left=10;
+	   		
+	   if ( left = 5 )
+	   {
+	      puts(" Values are equal...");
+	   }
+        }
+
+The program assigns 5 to the variable left and returns 5. +This is interpreted as
TRUE and causes the +puts statement to be executed everytime. +

+Here is the corrected program. +

+	main()
+	{
+	   int left=10;
+	   		
+	   if ( left == 5 )		/* Double equals required. */
+	   {
+	      puts(" Values are equal...");
+	   }
+        }
+
+ +
+ +
+

See Also:

+ + +Coding idioms.

+ +

+ +


+

+

+ + + + +
+ Top + + Master Index + + Keywords + + Functions +
+
+

+


+
Martin Leslie +

+ + -- cgit v1.2.3-54-g00ecf