none
setting up visual studio RRS feed

  • Question

  • hi guys, 

    I am new to programming in general and to visual studio so bear with mee. I have installed visual studio, but whe n putting in code after creating a project it doesn't compile. basically my question is how to solve this issue, so i can start going through the c++ book i am reading. The output is:

    1>------ Build started: Project: ConsoleApplication4, Configuration: Debug Win32 ------
    1>  ConsoleApplication4.cpp
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2065: 'cout' : undeclared identifier
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2137: empty character constant
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2146: syntax error : missing ';' before identifier 'it'
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2065: 'it' : undeclared identifier
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2146: syntax error : missing ';' before identifier 'works'
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2065: 'works' : undeclared identifier
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2143: syntax error : missing ';' before '!'
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    kind regards a current noob and hopefully not in the future. 

    Saturday, May 9, 2015 4:10 PM

Answers

  • 1>------ Build started: Project: ConsoleApplication4, Configuration: Debug Win32 ------
    1>  ConsoleApplication4.cpp
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2065: 'cout' : undeclared identifier
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2137: empty character constant
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2146: syntax error : missing ';' before identifier 'it'
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2065: 'it' : undeclared identifier
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2146: syntax error : missing ';' before identifier 'works'
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2065: 'works' : undeclared identifier
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2143: syntax error : missing ';' before '!'
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


    Judging from the particular errors you posted, it appears that you have used two single
    quote characters before and after the string to be displayed:

    ''it works!''

    when you should have a single double quote character before and after the string:

    "it works!"
    


    Also, the first error re cout being undeclared could be happening because cout is in the
    std namespace now. So in current compilers you have to specify it. There are three common
    ways to do that. Try this one:

    std::cout << "it works!";
    

    Note that older textbooks may not cover the std namespace so may not have it in the examples.

    Note also that you should always state which version of Visual Studio you're using, as
    features, procedures, bugs, etc. vary from version to version.

    - Wayne

    • Marked as answer by L0m1s Sunday, May 10, 2015 7:07 AM
    Saturday, May 9, 2015 8:57 PM

All replies

  • On 5/9/2015 12:10 PM, L0m1s wrote:

    1>------ Build started: Project: ConsoleApplication4, Configuration: Debug Win32 ------
    1>  ConsoleApplication4.cpp
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2065: 'cout' : undeclared identifier

    My crystal ball is cloudy lately, I have difficulty seeing your monitor from here. What code do you have on line 9 of consoleapplication4.cpp ?


    Igor Tandetnik
    Saturday, May 9, 2015 4:28 PM
  • Cout << "it works ! ";
    Saturday, May 9, 2015 4:52 PM
  • Since the error message is complaining about the identifier "cout", not "Cout", it is very unlikely that you have provided us the statement in your program.  When providing code, use cut and paste.  Do not retype.  Also use the insert code block feature.

    If you follow those recommendations and provide us with the first 20 or so lines of function, we may be able to help.

    Saturday, May 9, 2015 5:39 PM
  • 1>------ Build started: Project: ConsoleApplication4, Configuration: Debug Win32 ------
    1>  ConsoleApplication4.cpp
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2065: 'cout' : undeclared identifier
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2137: empty character constant
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2146: syntax error : missing ';' before identifier 'it'
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2065: 'it' : undeclared identifier
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2146: syntax error : missing ';' before identifier 'works'
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2065: 'works' : undeclared identifier
    1>c:\users\daniel\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(9): error C2143: syntax error : missing ';' before '!'
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


    Judging from the particular errors you posted, it appears that you have used two single
    quote characters before and after the string to be displayed:

    ''it works!''

    when you should have a single double quote character before and after the string:

    "it works!"
    


    Also, the first error re cout being undeclared could be happening because cout is in the
    std namespace now. So in current compilers you have to specify it. There are three common
    ways to do that. Try this one:

    std::cout << "it works!";
    

    Note that older textbooks may not cover the std namespace so may not have it in the examples.

    Note also that you should always state which version of Visual Studio you're using, as
    features, procedures, bugs, etc. vary from version to version.

    - Wayne

    • Marked as answer by L0m1s Sunday, May 10, 2015 7:07 AM
    Saturday, May 9, 2015 8:57 PM