Errors in compilation of simple programme

Discussion in 'C++' started by ftjonsson@gmail.com, Apr 9, 2007.

  1. Guest

    hello,

    I was wondering if anyone could tips me on what I am doing wrong when
    writing the following code:

    #include <iostream>
    using namespace std;

    int main ()
    {
    int i;

    cout >> "Hur gammal \x84r du? ";
    cin << i;

    cout >> "Jaha...du \x84r" >> i >> " \x86r gammal.";

    return 0;

    I recieve the following errors:
    ------ Build started: Project: Program 1, Configuration: Debug Win32
    ------
    Compiling...
    Program 1.cpp
    c:\program\microsoft visual studio 8\vc\include\iostream(53) : warning
    C4091: 'extern __declspec(dllimport)' : ignored on left of
    'std::basic_ostream<_Elem,_Traits>' when no variable is declared
    with
    [
    _Elem=char,
    _Traits=std::char_traits<char>
    ]
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(15) : error C2065:
    'cout' : undeclared identifier
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not
    deduce template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(927) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not
    deduce template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(927) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not
    deduce template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(927) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not
    deduce template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(927) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could
    not deduce template argument for 'std::basic_ostream<char,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(920) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could
    not deduce template argument for 'std::basic_ostream<char,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(920) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could
    not deduce template argument for 'std::basic_ostream<char,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(920) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could
    not deduce template argument for 'std::basic_ostream<char,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(920) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce
    template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(913) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce
    template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(913) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce
    template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(913) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce
    template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(913) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could
    not deduce template argument for 'std::basic_ostream<char,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(906) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could
    not deduce template argument for 'std::basic_ostream<char,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(906) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could
    not deduce template argument for 'std::basic_ostream<char,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(906) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could
    not deduce template argument for 'std::basic_ostream<char,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(906) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce
    template argument for 'std::basic_ostream<_Elem,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(868) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce
    template argument for 'std::basic_ostream<_Elem,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(868) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce
    template argument for 'std::basic_ostream<_Elem,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(868) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce
    template argument for 'std::basic_ostream<_Elem,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(868) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not
    deduce template argument for 'std::basic_ostream<_Elem,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(822) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not
    deduce template argument for 'std::basic_ostream<_Elem,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(822) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not
    deduce template argument for 'std::basic_ostream<_Elem,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(822) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not
    deduce template argument for 'std::basic_ostream<_Elem,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(822) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce
    template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(782) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce
    template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(782) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce
    template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(782) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce
    template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(782) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,const char *)' : could not
    deduce template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(735) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,const char *)' : could not
    deduce template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(735) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,const char *)' : could not
    deduce template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(735) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<char,_Traits> &std::eek:perator
    <<(std::basic_ostream<char,_Traits> &,const char *)' : could not
    deduce template argument for 'std::basic_ostream<char,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(735) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce
    template argument for 'std::basic_ostream<_Elem,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(697) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce
    template argument for 'std::basic_ostream<_Elem,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(697) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce
    template argument for 'std::basic_ostream<_Elem,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(697) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce
    template argument for 'std::basic_ostream<_Elem,_Traits> &' from
    'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(697) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not
    deduce template argument for 'std::basic_ostream<_Elem,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(650) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not
    deduce template argument for 'std::basic_ostream<_Elem,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(650) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not
    deduce template argument for 'std::basic_ostream<_Elem,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(650) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2784:
    'std::basic_ostream<_Elem,_Traits> &std::eek:perator
    <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not
    deduce template argument for 'std::basic_ostream<_Elem,_Traits> &'
    from 'std::istream'
    c:\program\microsoft visual studio 8\vc\include\ostream(650) :
    see declaration of 'std::eek:perator <<'
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(16) : error C2676:
    binary '<<' : 'std::istream' does not define this operator or a
    conversion to a type acceptable to the predefined operator
    Build log was saved at "file://c:\Documents and Settings\HP_Ägaren
    \Mina dokument\Visual Studio 2005\Projects\Program 1\Program 1\Debug
    \BuildLog.htm"
    Program 1 - 42 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
    ==========




    Any help would be appreciated!

    Thanks
     
    , Apr 9, 2007
    #1
    1. Advertising

  2. wrote:
    > hello,
    >
    > I was wondering if anyone could tips me on what I am doing wrong when
    > writing the following code:
    >
    > #include <iostream>
    > using namespace std;
    >
    > int main ()
    > {
    > int i;


    I recommend initialising it to 0.

    >
    > cout >> "Hur gammal \x84r du? ";
    > cin << i;


    You got your shifts wrong. You shift *left* with 'cout' and *right*
    with 'cin':

    cout << "Hur gammal \x84r du? ";
    cin >> i;

    >
    > cout >> "Jaha...du \x84r" >> i >> " \x86r gammal.";
    >
    > return 0;
    >
    > I recieve the following errors:
    > [..]


    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Apr 9, 2007
    #2
    1. Advertising

  3. acc15 Guest

    Hello!
    09.04.2007 at 17:18:29, <> wrote:

    > hello,
    >
    > I was wondering if anyone could tips me on what I am doing wrong when
    > writing the following code:
    >
    > #include <iostream>
    > using namespace std;
    >
    > int main ()
    > {
    > int i;
    >
    > cout >> "Hur gammal \x84r du? ";
    > cin << i;
    >
    > cout >> "Jaha...du \x84r" >> i >> " \x86r gammal.";
    >
    > return 0;
    >
    > I recieve the following errors:
    > [Skip]
    > Any help would be appreciated!
    >
    > Thanks
    >


    You forget about close bracket... i.e.
    #include <iostream>
    using namespace std;

    int main ()
    {
    int i;

    cout >> "Hur gammal \x84r du? ";
    cin << i;

    cout >> "Jaha...du \x84r" >> i >> " \x86r gammal.";

    return 0;
    } // <--- THIS IS REQUIRED!!

    --
    Best regards, acc15
     
    acc15, Apr 9, 2007
    #3
  4. Guest

    On 9 Apr, 15:26, "Victor Bazarov" <> wrote:
    > wrote:
    > > hello,

    >
    > > I was wondering if anyone could tips me on what I am doing wrong when
    > > writing the following code:

    >
    > > #include <iostream>
    > > using namespace std;

    >
    > > int main ()
    > > {
    > > int i;

    >
    > I recommend initialising it to 0.
    >
    >
    >
    > > cout >> "Hur gammal \x84r du? ";
    > > cin << i;

    >
    > You got your shifts wrong. You shift *left* with 'cout' and *right*
    > with 'cin':
    >
    > cout << "Hur gammal \x84r du? ";
    > cin >> i;
    >
    >
    >
    > > cout >> "Jaha...du \x84r" >> i >> " \x86r gammal.";

    >
    > > return 0;

    >



    I fixed the obvious mistake and felt a little ashamed... but now it
    spits out the following when compiling (exact same code with the
    opposite shifts):

    ------ Build started: Project: Program 1, Configuration: Debug Win32
    ------
    Compiling...
    Program 1.cpp
    c:\program\microsoft visual studio 8\vc\include\iostream(53) : warning
    C4091: 'extern __declspec(dllimport)' : ignored on left of
    'std::basic_ostream<_Elem,_Traits>' when no variable is declared
    with
    [
    _Elem=char,
    _Traits=std::char_traits<char>
    ]
    c:\documents and settings\hp_ägaren\mina dokument\visual studio
    2005\projects\program 1\program 1\program 1.cpp(15) : error C2065:
    'cout' : undeclared identifier
    Build log was saved at "file://c:\Documents and Settings\HP_Ägaren
    \Mina dokument\Visual Studio 2005\Projects\Program 1\Program 1\Debug
    \BuildLog.htm"
    Program 1 - 1 error(s), 1 warning(s)


    @acc15

    sorry about that...the last bracket w a s in, i just didnt paste it in
     
    , Apr 9, 2007
    #4
  5. wrote:
    > On 9 Apr, 15:26, "Victor Bazarov" <> wrote:
    >> wrote:
    >>> hello,

    >>
    >>> I was wondering if anyone could tips me on what I am doing wrong
    >>> when writing the following code:

    >>
    >>> #include <iostream>
    >>> using namespace std;

    >>
    >>> int main ()
    >>> {
    >>> int i;

    >>
    >> I recommend initialising it to 0.
    >>
    >>
    >>
    >>> cout >> "Hur gammal \x84r du? ";
    >>> cin << i;

    >>
    >> You got your shifts wrong. You shift *left* with 'cout' and *right*
    >> with 'cin':
    >>
    >> cout << "Hur gammal \x84r du? ";
    >> cin >> i;
    >>
    >>
    >>
    >>> cout >> "Jaha...du \x84r" >> i >> " \x86r gammal.";

    >>
    >>> return 0;

    >>

    >
    >
    > I fixed the obvious mistake and felt a little ashamed... but now it
    > spits out the following when compiling (exact same code with the
    > opposite shifts):
    >
    > ------ Build started: Project: Program 1, Configuration: Debug Win32
    > ------
    > Compiling...
    > Program 1.cpp
    > c:\program\microsoft visual studio 8\vc\include\iostream(53) : warning
    > C4091: 'extern __declspec(dllimport)' : ignored on left of
    > 'std::basic_ostream<_Elem,_Traits>' when no variable is declared
    > with
    > [
    > _Elem=char,
    > _Traits=std::char_traits<char>
    > ]
    > c:\documents and settings\hp_ägaren\mina dokument\visual studio
    > 2005\projects\program 1\program 1\program 1.cpp(15) : error C2065:
    > 'cout' : undeclared identifier


    You did include <iostream>, didn't you? Then the reason for this error
    is probably the warning up above.

    > Build log was saved at "file://c:\Documents and Settings\HP_Ägaren
    > \Mina dokument\Visual Studio 2005\Projects\Program 1\Program 1\Debug
    > \BuildLog.htm"
    > Program 1 - 1 error(s), 1 warning(s)


    We can't help you with that, sorry. The "_declspec(dllimport)" syntax
    is specific to Visual C++. Post to 'microsoft.public.vc.language'
    about it. They should know.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Apr 9, 2007
    #5
  6. Guest

    On 9 Apr, 15:57, "Victor Bazarov" <> wrote:
    > wrote:
    > > On 9 Apr, 15:26, "Victor Bazarov" <> wrote:
    > >> wrote:
    > >>> hello,

    >
    > >>> I was wondering if anyone could tips me on what I am doing wrong
    > >>> when writing the following code:

    >
    > >>> #include <iostream>
    > >>> using namespace std;

    >
    > >>> int main ()
    > >>> {
    > >>> int i;

    >
    > >> I recommend initialising it to 0.

    >
    > >>> cout >> "Hur gammal \x84r du? ";
    > >>> cin << i;

    >
    > >> You got your shifts wrong. You shift *left* with 'cout' and *right*
    > >> with 'cin':

    >
    > >> cout << "Hur gammal \x84r du? ";
    > >> cin >> i;

    >
    > >>> cout >> "Jaha...du \x84r" >> i >> " \x86r gammal.";

    >
    > >>> return 0;

    >
    > > I fixed the obvious mistake and felt a little ashamed... but now it
    > > spits out the following when compiling (exact same code with the
    > > opposite shifts):

    >
    > > ------ Build started: Project: Program 1, Configuration: Debug Win32
    > > ------
    > > Compiling...
    > > Program 1.cpp
    > > c:\program\microsoft visual studio 8\vc\include\iostream(53) : warning
    > > C4091: 'extern __declspec(dllimport)' : ignored on left of
    > > 'std::basic_ostream<_Elem,_Traits>' when no variable is declared
    > > with
    > > [
    > > _Elem=char,
    > > _Traits=std::char_traits<char>
    > > ]
    > > c:\documents and settings\hp_ägaren\mina dokument\visual studio
    > > 2005\projects\program 1\program 1\program 1.cpp(15) : error C2065:
    > > 'cout' : undeclared identifier

    >
    > You did include <iostream>, didn't you? Then the reason for this error
    > is probably the warning up above.
    >
    > > Build log was saved at "file://c:\Documents and Settings\HP_Ägaren
    > > \Mina dokument\Visual Studio 2005\Projects\Program 1\Program 1\Debug
    > > \BuildLog.htm"
    > > Program 1 - 1 error(s), 1 warning(s)

    >
    > We can't help you with that, sorry. The "_declspec(dllimport)" syntax
    > is specific to Visual C++. Post to 'microsoft.public.vc.language'
    > about it. They should know.
    >
    > V
    > --
    > Please remove capital 'A's when replying by e-mail
    > I do not respond to top-posted replies, please don't ask- Dölj citerad text -
    >
    > - Visa citerad text -


    Yes, <iostream> is included. Thanks for the help, I will check with
    them!

    Cheers
     
    , Apr 9, 2007
    #6
  7. Fei Liu Guest

    acc15 wrote:
    > Hello!
    > 09.04.2007 at 17:18:29, <> wrote:
    >
    >> hello,
    >>
    >> I was wondering if anyone could tips me on what I am doing wrong when
    >> writing the following code:
    >>
    >> #include <iostream>
    >> using namespace std;
    >>
    >> int main ()
    >> {
    >> int i;
    >>
    >> cout >> "Hur gammal \x84r du? ";
    >> cin << i;
    >>
    >> cout >> "Jaha...du \x84r" >> i >> " \x86r gammal.";
    >>
    >> return 0;
    >>
    >> I recieve the following errors:
    >> [Skip]
    >> Any help would be appreciated!
    >>
    >> Thanks
    >>

    >
    > You forget about close bracket... i.e.
    > #include <iostream>
    > using namespace std;
    >
    > int main ()
    > {
    > int i;
    >
    > cout >> "Hur gammal \x84r du? ";
    > cin << i;
    >
    > cout >> "Jaha...du \x84r" >> i >> " \x86r gammal.";
    >
    > return 0;
    > } // <--- THIS IS REQUIRED!!
    >
    > --Best regards, acc15


    However most of the errors are related to his use of cout and cin.
    Notice how the direction of the arrows are all wrong?
     
    Fei Liu, Apr 9, 2007
    #7
  8. acc15 Guest

    Hello!
    09.04.2007 at 17:47:55, <> wrote:

    > On 9 Apr, 15:26, "Victor Bazarov" <> wrote:
    >> wrote:
    >> > hello,

    >>
    >> > I was wondering if anyone could tips me on what I am doing wrong when
    >> > writing the following code:

    >>
    >> > #include <iostream>
    >> > using namespace std;

    >>
    >> > int main ()
    >> > {
    >> > int i;

    >>
    >> I recommend initialising it to 0.
    >>
    >>
    >>
    >> > cout >> "Hur gammal \x84r du? ";
    >> > cin << i;

    >>
    >> You got your shifts wrong. You shift *left* with 'cout' and *right*
    >> with 'cin':
    >>
    >> cout << "Hur gammal \x84r du? ";
    >> cin >> i;
    >>
    >>
    >>
    >> > cout >> "Jaha...du \x84r" >> i >> " \x86r gammal.";

    >>
    >> > return 0;

    >>

    >
    >
    > I fixed the obvious mistake and felt a little ashamed... but now it
    > spits out the following when compiling (exact same code with the
    > opposite shifts):
    >
    > ------ Build started: Project: Program 1, Configuration: Debug Win32
    > ------
    > Compiling...
    > Program 1.cpp
    > c:\program\microsoft visual studio 8\vc\include\iostream(53) : warning
    > C4091: 'extern __declspec(dllimport)' : ignored on left of
    > 'std::basic_ostream<_Elem,_Traits>' when no variable is declared
    > with
    > [
    > _Elem=char,
    > _Traits=std::char_traits<char>
    > ]
    > c:\documents and settings\hp_ägaren\mina dokument\visual studio
    > 2005\projects\program 1\program 1\program 1.cpp(15) : error C2065:
    > 'cout' : undeclared identifier
    > Build log was saved at "file://c:\Documents and Settings\HP_Ägaren
    > \Mina dokument\Visual Studio 2005\Projects\Program 1\Program 1\Debug
    > \BuildLog.htm"
    > Program 1 - 1 error(s), 1 warning(s)
    >
    >
    > @acc15
    >
    > sorry about that...the last bracket w a s in, i just didnt paste it in
    >


    As Victor said: The problem explicitly in arrow directions...
    This code is right and works properly on my machine (VS 2005 PRO):

    #include <iostream>
    using namespace std;

    int main ()
    {
    int i;

    cout << "Hur gammal \x84r du? ";
    cin >> i;

    cout << "Jaha...du \x84r" << i << " \x86r gammal.";

    return 0;
    }

    Solution:
    1. Create new console project with default settings (exception: without
    Precompiled Headers!)
    2. Create new file named 'main.cpp'.
    3. Insert code listed above.
    4. Build it.

    Must working...
    Otherwise the trouble is somewhere in Visual Studio settings. Try to
    reinstall it.

    --
    Best regards, acc15
     
    acc15, Apr 9, 2007
    #8
  9. Guest

    On 9 Apr, 17:15, acc15 <> wrote:
    > Hello!
    > 09.04.2007 at 17:47:55, <> wrote:
    >
    >
    >
    >
    >
    > > On 9 Apr, 15:26, "Victor Bazarov" <> wrote:
    > >> wrote:
    > >> > hello,

    >
    > >> > I was wondering if anyone could tips me on what I am doing wrong when
    > >> > writing the following code:

    >
    > >> > #include <iostream>
    > >> > using namespace std;

    >
    > >> > int main ()
    > >> > {
    > >> > int i;

    >
    > >> I recommend initialising it to 0.

    >
    > >> > cout >> "Hur gammal \x84r du? ";
    > >> > cin << i;

    >
    > >> You got your shifts wrong. You shift *left* with 'cout' and *right*
    > >> with 'cin':

    >
    > >> cout << "Hur gammal \x84r du? ";
    > >> cin >> i;

    >
    > >> > cout >> "Jaha...du \x84r" >> i >> " \x86r gammal.";

    >
    > >> > return 0;

    >
    > > I fixed the obvious mistake and felt a little ashamed... but now it
    > > spits out the following when compiling (exact same code with the
    > > opposite shifts):

    >
    > > ------ Build started: Project: Program 1, Configuration: Debug Win32
    > > ------
    > > Compiling...
    > > Program 1.cpp
    > > c:\program\microsoft visual studio 8\vc\include\iostream(53) : warning
    > > C4091: 'extern __declspec(dllimport)' : ignored on left of
    > > 'std::basic_ostream<_Elem,_Traits>' when no variable is declared
    > > with
    > > [
    > > _Elem=char,
    > > _Traits=std::char_traits<char>
    > > ]
    > > c:\documents and settings\hp_ägaren\mina dokument\visual studio
    > > 2005\projects\program 1\program 1\program 1.cpp(15) : error C2065:
    > > 'cout' : undeclared identifier
    > > Build log was saved at "file://c:\Documents and Settings\HP_Ägaren
    > > \Mina dokument\Visual Studio 2005\Projects\Program 1\Program 1\Debug
    > > \BuildLog.htm"
    > > Program 1 - 1 error(s), 1 warning(s)

    >
    > > @acc15

    >
    > > sorry about that...the last bracket w a s in, i just didnt paste it in

    >
    > As Victor said: The problem explicitly in arrow directions...
    > This code is right and works properly on my machine (VS 2005 PRO):
    >
    > #include <iostream>
    > using namespace std;
    >
    > int main ()
    > {
    > int i;
    >
    > cout << "Hur gammal \x84r du? ";
    > cin >> i;
    >
    > cout << "Jaha...du \x84r" << i << " \x86r gammal.";
    >
    > return 0;
    >
    > }
    >
    > Solution:
    > 1. Create new console project with default settings (exception: without
    > Precompiled Headers!)
    > 2. Create new file named 'main.cpp'.
    > 3. Insert code listed above.
    > 4. Build it.
    >
    > Must working...
    > Otherwise the trouble is somewhere in Visual Studio settings. Try to
    > reinstall it.
    >
    > --
    > Best regards, acc15- Dölj citerad text -
    >
    > - Visa citerad text -


    Thanks for the info. I tried doing as you wrote acc15, but no luck. So
    now I am going to see what is wrong with my computer, or try with a
    completely different program. (No precompiled header, renamed the file
    inserted the code, console app., build gave me a warning and an error,
    the same as above.
     
    , Apr 9, 2007
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    955
    Mark Goldin
    Jan 17, 2004
  2. Replies:
    2
    Views:
    382
    Scott Allen
    May 5, 2005
  3. Nobber

    Diary Programme?

    Nobber, Nov 18, 2005, in forum: Java
    Replies:
    2
    Views:
    432
    Monique Y. Mudama
    Nov 18, 2005
  4. C__chp
    Replies:
    4
    Views:
    507
    Puppet_Sock
    Feb 15, 2008
  5. guptha
    Replies:
    7
    Views:
    310
Loading...

Share This Page