Djgpp error, possibly with the headings i'm using

This is a discussion on Djgpp error, possibly with the headings i'm using within the C++ Programming forums, part of the General Programming Boards category; OK I'm getting error messages doing the simplest program available, it could be an error with a header or djgpp ...

  1. #1
    Unregistered
    Guest

    Djgpp error, possibly with the headings i'm using

    OK I'm getting error messages doing the simplest program available, it could be an error with a header or djgpp or I dont know...I have been using djgpp for nearly 2 days and its my first compiler, so thats about how much experience i have.\
    THE PROGRAM

    #include <iostream.h>
    int main()
    {
    cout>>"heY";
    return 0;
    }

    Plz helP! ty

  2. #2
    Unregistered
    Guest

    Arrow oops i forgot

    Ok I'm about bright, totally forgot the error messagez...
    (Give me a break, itz my first time =|



    C:\djgpp>gcc test.cc -o test.exe -lm
    In file included from c:/djgpp/lang/cxx-v31/backward/iostream.h:31, from test.cc:1:
    c:/djgpp/lang/cxx-v31/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
    test.cc: In function `int main()':
    test.cc:4: no match for `std:stream& >> const char[4]' operator
    test.cc:6:2: warning: no newline at end of file


    ty
    --NewbiE

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    10
    I am kinda new at C++ and I don't know anything about djgpp but try this.

    Code:
    #include <iostream> 
    
    int main() 
    { 
    std::cout << "heY"; 
    return 0; 
    }

  4. #4
    Registered User fletch's Avatar
    Join Date
    Jul 2002
    Posts
    176
    try:

    Code:
    #include <iostream>
    #include <stdlib.h>
    
    int main()
    {
        std::cout << "Hey!";
        return 0;
    }
    Couple of things...
    1) <iostream> instead of <iostream.h>.

    2) 'std::cout' vice 'cout'. Placing 'std::' tells the compilier what object the cout function is in. As an alternative, you could include 'using namespace std;' at the beginning of main. This tells the compiler to look for otherwise undefined functions in the std object.

    3) The redirection operator. The redirection operators >> and << basically show the direction of data flow. In your original program you had:
    Code:
     cout>>"heY";
    What you've said is take the output from cout and pass it to the string "HeY". Two problems 1) cout doesn't return anything and 2) "HeY" isn't a variable and can't accept any values. The statement
    Code:
    std::cout << "Hey!";
    passes the string "Hey!" to the function cout which, in turn, displays it on your monitor. As you learn C++ you'll use the >> redirection operator in things like 'cin >> MyVar' which takes input from the user and places it into MyVar.

    fletch
    "Logic is the art of going wrong with confidence."
    Morris Kline

  5. #5
    Unregistered
    Guest

    j

    It's still not working...I got these errors anyway

    C:\djgpp>gcc test.cc -o test.exe -lm
    c:/djgpp/tmp/cc35pF8W.o(.text+0x1f):test.cc: undefined reference to `std::cout'
    c:/djgpp/tmp/cc35pF8W.o(.text+0x24):test.cc: undefined reference to `std::basic_
    ostream<char, std::char_traits<char> >& std:perator<< <std::char_traits<char>
    >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
    c:/djgpp/tmp/cc35pF8W.o(.text+0x50):test.cc: undefined reference to `std::ios_ba
    se::Init::Init[in-charge]()'
    c:/djgpp/tmp/cc35pF8W.o(.text+0x6f):test.cc: undefined reference to `std::ios_ba
    se::Init::~Init [in-charge]()'
    c:/djgpp/tmp/cc35pF8W.o(.eh_frame+0x11):test.cc: undefined reference to `___gxx_
    personality_v0'
    collect2: ld returned 1 exit status

    using this:

    #include <iostream>
    #include <stdlib.h>

    int main()
    {
    std::cout << "Hey!";
    return 0;
    }

    So im still @)$#ed

  6. #6
    Registered User fletch's Avatar
    Join Date
    Jul 2002
    Posts
    176
    Don't know what to tell you. That little snippet of code should work. Have you tried reinstalling/redownloading your compiler to make sure your copy is the most recent version and is uncorrupted? Or maybe try another compiler?

    DJGPP Homepage
    Dev C++
    Borland C++
    "Logic is the art of going wrong with confidence."
    Morris Kline

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,418
    gcc is the c compiler, gxx is the c++ compiler

    Try
    gxx test.cc -o test.exe -lm

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Wav edit programmation for dos with DJGPP
    By sprudhom in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 07-17-2003, 07:35 AM
  2. Is Allegro + DJGPP a no-no?
    By Stan100 in forum Game Programming
    Replies: 4
    Last Post: 10-03-2002, 07:34 PM
  3. DJGPP project problems
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 06-08-2002, 07:16 PM
  4. DJGPP assembly syntax ills...
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 11-11-2001, 01:54 AM
  5. DJGPP help needed
    By dune911 in forum C++ Programming
    Replies: 6
    Last Post: 09-15-2001, 04:56 PM

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