Need a hand with while loops and some funky error messages

This is a discussion on Need a hand with while loops and some funky error messages within the C++ Programming forums, part of the General Programming Boards category; I'm trying just to mkae a simple while loop and I am getting the following errors..... c:\Documents and Settings\Philip McCarthy\My ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    33

    Need a hand with while loops and some funky error messages

    I'm trying just to mkae a simple while loop and I am getting the following errors.....
    c:\Documents and Settings\Philip McCarthy\My Documents\Visual Studio Projects\messin\messin.cpp(32) : error C2001: newline in constant
    c:\Documents and Settings\Philip McCarthy\My Documents\Visual Studio Projects\messin\messin.cpp(37) : error C2143: syntax error : missing ';' before 'return'
    c:\Documents and Settings\Philip McCarthy\My Documents\Visual Studio Projects\messin\messin.cpp(32) : error C3861: 'setw': identifier not found, even with argument-dependent lookup



    Here's the code I can't seem to figure out what I'm missing =/

    Code:
    #include <iostream>
    
    using namespace std;
    
    const int INCREMENT_VALUE = 5;
    
    
    
    int main()
    {
    	int count;
    	int result;
    
    
    	count = 0;
    	result = 150;
    
    	cout<<"Column Heading: "<<"Count "<<"     result "<<endl;
    
    	cout<<"        Output:    "<<count<<"       "<<result<<endl;
    
    	while (result < 0)
    	{
    
        count = (result  count * count);
    
    	cout<<"        Output:    "<<count<<"       "<<result<<endl;
    	}
    	cout<<setw(30)<<"test<<endl;
    
    
    
    
    return 0;
    }

    For some reason I can't use setw() ??

  2. #2
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    Code:
    cout<<setw(30)<<"test"<<endl;
    You were missing the second quote. And you must #include <iomanip> for setw.

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    33
    c:\Documents and Settings\Philip McCarthy\My Documents\Visual Studio Projects\messin\messin.cpp(26) : error C3209: ' count' : Unicode identifiers are not yet supported


    keeps beeping that one at me....is count a reserved word?

  4. #4
    Registered User
    Join Date
    Sep 2003
    Posts
    33
    updated code:

    Code:
    #include <iostream>
    #include <iomanip>
    
    using namespace std;
    
    const int INCREMENT_VALUE = 5;
    
    
    
    int main()
    
    {
    	int count;
    	int result;
    
    
    	count = 0;
    	result = 150;
    
    	cout<<"Column Heading: "<<"Count "<<"     result "<<endl;
    
    	cout<<"        Output:    "<<count<<"       "<<result<<endl;
    
    	while (result > 0);
    	{
    
        count = count + INCREMENT_VALUE;
        result = result  count * count;
    	
    	}
    
        cout<<"        Output:    "<<count<<"       "<<result<<endl;
    
    	cout<<setw(30)<<"test"<<endl;
    
    
    
    
    return 0;
    }
    Last edited by Furious_George; 10-22-2003 at 04:59 PM.

  5. #5
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    Your minus sign is not the regular minus sign... weird.

    delete it and type -.

    Also, you have a semicolon after your while expression. You should remove it or the loop won't work.

  6. #6
    Registered User
    Join Date
    Sep 2003
    Posts
    33
    lol retyped the minus and it worked....you rock!
    thanks for all the help

Popular pages Recent additions subscribe to a feed

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