Why won't this work?

This is a discussion on Why won't this work? within the C++ Programming forums, part of the General Programming Boards category; Why won't this work? Code: #include<iostream> using namespace std; int main() { int a,b,c; a = 6; b = 3; ...

  1. #1
    cout << "Bye World!";
    Join Date
    Jun 2006
    Posts
    40

    Why won't this work?

    Why won't this work?
    Code:
    #include<iostream>
    using namespace std;
    
    int main()
    {
    	int a,b,c;
    	a = 6;
    	b = 3;
    	c = (a%b);
                    cout << c;
    	if(c = 0)
    		cout << "c is my homie";
    	return 0;
    }
    Output: 0
    That's is - no "c is my homie". Why not? Thanks from the newbie!

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,209
    Code:
    if(c = 0)
    		cout << "c is my homie";
    should be

    Code:
    if(c == 0)
    		cout << "c is my homie";
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

  3. #3
    cout << "Bye World!";
    Join Date
    Jun 2006
    Posts
    40
    Duh! Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 08:48 PM
  2. getline() don't want to work anymore...
    By mikahell in forum C++ Programming
    Replies: 7
    Last Post: 07-31-2006, 11:50 AM
  3. Why don't the tutorials on this site work on my computer?
    By jsrig88 in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2006, 11:39 PM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. DLL __cdecl doesnt seem to work?
    By Xei in forum C++ Programming
    Replies: 6
    Last Post: 08-21-2002, 05:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21