Dev C++ Help again.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Redmoon
    New Member
    • Jul 2007
    • 3

    Dev C++ Help again.

    This is my second post and still am unable to understand why this simplest program cannot compile and run for me. I am not so understanding to much of anything but this is my real interest, learning c++. Here is my code. I have followed my tutoring book and comes out with errors and then execution aborts.

    Code:
    #include <iostream>
    #include <stdlib.h>
    
    int main(int argc, char *argv[])
    {
    cout<<Hello world.<<endl;
      
      system("PAUSE");	
      return 0;
    }
    Sorry in advance for wasting peoples time. I want to learn.
  • Meetee
    Recognized Expert Contributor
    • Dec 2006
    • 928

    #2
    Originally posted by Redmoon
    This is my second post and still am unable to understand why this simplest program cannot compile and run for me. I am not so understanding to much of anything but this is my real interest, learning c++. Here is my code. I have followed my tutoring book and comes out with errors and then execution aborts.

    Code:
    #include <iostream>
    #include <stdlib.h>
    
    int main(int argc, char *argv[])
    {
    cout<<Hello world.<<endl;
      
      system("PAUSE");	
      return 0;
    }
    Sorry in advance for wasting peoples time. I want to learn.
    Hi,
    There is no question of wasting time as here people are gathered to help. As far as your code is concerned, when I compiled your program it showed me errors which disappered when I tried this:
    Code:
    #include <iostream.h>
          #include <stdlib.h>
          using namespace std;
          int main(int argc, char *argv[])
          {
          cout<<"Hello world."<<endl;
          system("PAUSE");
          return 0;
          }
    However, in output it shows this:
    Hello world.
    sh: PAUSE: command not found

    If anybody can help here

    Regards

    Comment

    • Benny the Guard
      New Member
      • Jun 2007
      • 92

      #3
      "PAUSE" didn't work on your machine because its a Windows command, and you're using UNIX it appears. As for the other you're right just add:

      using namespace std;

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by Redmoon
        This is my second post and still am unable to understand why this simplest program cannot compile and run for me. I am not so understanding to much of anything but this is my real interest, learning c++. Here is my code. I have followed my tutoring book and comes out with errors and then execution aborts.

        Code:
        #include <iostream>
        #include <stdlib.h>
        
        int main(int argc, char *argv[])
        {
        cout<<Hello world.<<endl;
          
          system("PAUSE");	
          return 0;
        }
        Sorry in advance for wasting peoples time. I want to learn.
        When you have errors in your program, it's always a good idea to post the error message that you got. Aren't you supposed to using namespace std?

        Comment

        • Meetee
          Recognized Expert Contributor
          • Dec 2006
          • 928

          #5
          Originally posted by Benny the Guard
          "PAUSE" didn't work on your machine because its a Windows command, and you're using UNIX it appears. As for the other you're right just add:

          using namespace std;
          Ok Banny,

          Thanks :)

          Comment

          • Redmoon
            New Member
            • Jul 2007
            • 3

            #6
            Code:
            #include <iostream>
                #include <stdlib.h>
                using namespace std;
                int main(int argc, char *argv[])
                {
                cout<<Hello world!!!<<end1;  
                system("PAUSE");	
                return 0;
                }
            My errors in this project are 70. So here it is...

            My compiler log:

            Compiler: Default compiler
            Building Makefile: "C:\Dev-Cpp\Makefile.wi n"
            Executing make...
            make.exe -f "C:\Dev-Cpp\Makefile.wi n" all
            g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include/c++" -I"C:/Dev-Cpp/include"

            In file included from main.cpp:1:
            C:/Dev-Cpp/include/c++/iostream:44:28: bits/c++config.h: No such file or directory
            In file included from C:/Dev-Cpp/include/c++/ios:44,
            from C:/Dev-Cpp/include/c++/ostream:45,
            from C:/Dev-Cpp/include/c++/iostream:45,
            from main.cpp:1:
            C:/Dev-Cpp/include/c++/iosfwd:44:28: bits/c++config.h: No such file or directory
            In file included from C:/Dev-Cpp/include/c++/iosfwd:45,

            from C:/Dev-Cpp/include/c++/ios:44,
            from C:/Dev-Cpp/include/c++/ostream:45,

            from C:/Dev-Cpp/include/c++/iostream:45,
            from main.cpp:1:
            C:/Dev-Cpp/include/c++/bits/stringfwd.h:44: 28: bits/c++config.h: No such file or directory
            In file included from C:/Dev-Cpp/include/c++/iosfwd:46,
            from C:/Dev-Cpp/include/c++/ios:44,
            from C:/Dev-Cpp/include/c++/ostream:45,
            from C:/Dev-Cpp/include/c++/iostream:45,
            from main.cpp:1:
            C:/Dev-Cpp/include/c++/bits/fpos.h:44:24: bits/c++io.h: No such file or directory
            In file included from C:/Dev-Cpp/include/c++/bits/fpos.h:45,
            from C:/Dev-Cpp/include/c++/iosfwd:46,
            from C:/Dev-Cpp/include/c++/ios:44,
            from C:/Dev-Cpp/include/c++/ostream:45,
            from C:/Dev-Cpp/include/c++/iostream:45,
            from main.cpp:1:
            C:/Dev-Cpp/include/c++/cwchar:49:28: bits/c++config.h: No such file or directory
            In file included from C:/Dev-Cpp/include/c++/iosfwd:46,
            from C:/Dev-Cpp/include/c++/ios:44,
            from C:/Dev-Cpp/include/c++/ostream:45,
            from C:/Dev-Cpp/include/c++/iostream:45,
            from main.cpp:1:
            C:/Dev-Cpp/include/c++/bits/fpos.h:60: 'streamoff' is used as a type, but is
            not defined as a type.
            C:/Dev-Cpp/include/c++/bits/fpos.h:74: parse error before `__off'
            C:/Dev-Cpp/include/c++/bits/fpos.h:75: missing ';' before right brace
            C:/Dev-Cpp/include/c++/bits/fpos.h:77: semicolon missing after declaration of `
            std::fpos<_Stat eT>'
            C:/Dev-Cpp/include/c++/bits/fpos.h: In constructor
            `std::fpos<_Sta teT>::fpos()':
            C:/Dev-Cpp/include/c++/bits/fpos.h:72: class `std::fpos<_Sta teT>' does not have
            any field named `_M_off'
            C:/Dev-Cpp/include/c++/bits/fpos.h: At global scope:
            C:/Dev-Cpp/include/c++/bits/fpos.h:77: parse error before `(' token

            C:/Dev-Cpp/include/c++/bits/fpos.h:77: ISO C++ forbids defining types within
            return type
            C:/Dev-Cpp/include/c++/bits/fpos.h:77: syntax error before `(' token
            C:/Dev-Cpp/include/c++/bits/fpos.h:79: syntax error before `&' token
            C:/Dev-Cpp/include/c++/bits/fpos.h:82: syntax error before `&' token
            C:/Dev-Cpp/include/c++/bits/fpos.h:86: syntax error before `operator'
            C:/Dev-Cpp/include/c++/bits/fpos.h:89: syntax error before `+=' token
            C:/Dev-Cpp/include/c++/bits/fpos.h:94: syntax error before `operator'
            C:/Dev-Cpp/include/c++/bits/fpos.h:97: syntax error before `-=' token
            C:/Dev-Cpp/include/c++/bits/fpos.h:102: parse error before `&' token
            C:/Dev-Cpp/include/c++/bits/fpos.h:103: non-member function `bool
            operator==(...) ' cannot have `const' method qualifier
            C:/Dev-Cpp/include/c++/bits/fpos.h:103: `bool operator==(...) ' must have an
            argument of class or enumerated type
            C:/Dev-Cpp/include/c++/bits/fpos.h:103: `bool operator==(...) ' must take
            exactly two arguments
            C:/Dev-Cpp/include/c++/bits/fpos.h: In function `bool operator==(...) ':
            C:/Dev-Cpp/include/c++/bits/fpos.h:103: `_M_off' undeclared (first use this
            function)
            C:/Dev-Cpp/include/c++/bits/fpos.h:103: (Each undeclared identifier is reported
            only once for each function it appears in.)
            C:/Dev-Cpp/include/c++/bits/fpos.h:103: `__pos' undeclared (first use this
            function)
            C:/Dev-Cpp/include/c++/bits/fpos.h: At global scope:
            C:/Dev-Cpp/include/c++/bits/fpos.h:106: parse error before `&' token
            C:/Dev-Cpp/include/c++/bits/fpos.h:107: non-member function `bool
            operator!=(...) ' cannot have `const' method qualifier
            C:/Dev-Cpp/include/c++/bits/fpos.h:107: `bool operator!=(...) ' must have an
            argument of class or enumerated type

            C:/Dev-Cpp/include/c++/bits/fpos.h:107: `bool operator!=(...) ' must take
            exactly two arguments
            C:/Dev-Cpp/include/c++/bits/fpos.h:110: parse error before `)' token
            C:/Dev-Cpp/include/c++/bits/fpos.h:113: `streamoff' was not declared in this
            scope
            C:/Dev-Cpp/include/c++/bits/fpos.h:113: parse error before `)' token
            C:/Dev-Cpp/include/c++/bits/fpos.h: In function `void _M_position(... )':
            C:/Dev-Cpp/include/c++/bits/fpos.h:113: `__off' undeclared (first use this
            function)
            C:/Dev-Cpp/include/c++/bits/fpos.h: At global scope:
            C:/Dev-Cpp/include/c++/bits/fpos.h:114: parse error before `}' token
            C:/Dev-Cpp/include/c++/bits/fpos.h:117: syntax error before `;' token

            In file included from C:/Dev-Cpp/include/c++/ios:46,
            from C:/Dev-Cpp/include/c++/ostream:45,

            from C:/Dev-Cpp/include/c++/iostream:45,
            from main.cpp:1:
            C:/Dev-Cpp/include/c++/bits/char_traits.h:5 9: parse error before `;' token
            C:/Dev-Cpp/include/c++/bits/char_traits.h:6 0: parse error before `;' token
            C:/Dev-Cpp/include/c++/bits/char_traits.h:1 13: parse error before `;' token
            C:/Dev-Cpp/include/c++/bits/char_traits.h:1 14: parse error before `;' token

            C:/Dev-Cpp/include/c++/bits/char_traits.h: In static member function `static
            int std::char_trait s<char>::eof()' :
            C:/Dev-Cpp/include/c++/bits/char_traits.h:1 68: `EOF' undeclared (first use this
            function)

            In file included from C:/Dev-Cpp/include/c++/ios:47,
            from C:/Dev-Cpp/include/c++/ostream:45,

            from C:/Dev-Cpp/include/c++/iostream:45,
            from main.cpp:1:
            C:/Dev-Cpp/include/c++/cstdio:49:28: bits/c++config.h: No such file or directory

            In file included from C:/Dev-Cpp/include/c++/ios:48,
            from C:/Dev-Cpp/include/c++/ostream:45,

            from C:/Dev-Cpp/include/c++/iostream:45,
            from main.cpp:1:
            C:/Dev-Cpp/include/c++/bits/localefwd.h:45: 28: bits/c++config.h: No such file or directory
            C:/Dev-Cpp/include/c++/bits/localefwd.h:46: 80: bits/c++locale.h: No such file or directory
            In file included from C:/Dev-Cpp/include/c++/bits/localefwd.h:48,
            from C:/Dev-Cpp/include/c++/ios:48,
            from C:/Dev-Cpp/include/c++/ostream:45,
            from C:/Dev-Cpp/include/c++/iostream:45,
            from main.cpp:1:
            C:/Dev-Cpp/include/c++/cctype:48:28: bits/c++config.h: No such file or directory
            In file included from C:/Dev-Cpp/include/c++/bits/localefwd.h:49,
            from C:/Dev-Cpp/include/c++/ios:48,
            from C:/Dev-Cpp/include/c++/ostream:45,
            from C:/Dev-Cpp/include/c++/iostream:45,
            from main.cpp:1:
            C:/Dev-Cpp/include/c++/string:45:28: bits/c++config.h: No such file or directory
            In file included from C:/Dev-Cpp/include/c++/memory:54,
            from C:/Dev-Cpp/include/c++/string:48,
            from C:/Dev-Cpp/include/c++/bits/localefwd.h:49,
            from C:/Dev-Cpp/include/c++/ios:48,
            from C:/Dev-Cpp/include/c++/ostream:45,
            from C:/Dev-Cpp/include/c++/iostream:45,
            from main.cpp:1:
            C:/Dev-Cpp/include/c++/bits/stl_algobase.h: 64:28: bits/c++config.h: No such file or directory
            In file included from C:/Dev-Cpp/include/c++/bits/stl_algobase.h: 67,
            from C:/Dev-Cpp/include/c++/memory:54,
            from C:/Dev-Cpp/include/c++/string:48,
            from C:/Dev-Cpp/include/c++/bits/localefwd.h:49,
            from C:/Dev-Cpp/include/c++/ios:48,
            from C:/Dev-Cpp/include/c++/ostream:45,
            from C:/Dev-Cpp/include/c++/iostream:45,
            from main.cpp:1:
            C:/Dev-Cpp/include/c++/cstdlib:49:28: bits/c++config.h: No such file or directory
            In file included from C:/Dev-Cpp/include/c++/bits/stl_algobase.h: 72,

            from C:/Dev-Cpp/include/c++/memory:54,
            from C:/Dev-Cpp/include/c++/string:48,
            from C:/Dev-Cpp/include/c++/bits/localefwd.h:49,
            from C:/Dev-Cpp/include/c++/ios:48,
            from C:/Dev-Cpp/include/c++/ostream:45,
            from C:/Dev-Cpp/include/c++/iostream:45,

            from main.cpp:1:
            C:/Dev-Cpp/include/c++/bits/type_traits.h:5 4:28: bits/c++config.h: No such file or directory
            In file included from C:/Dev-Cpp/include/c++/bits/stl_iterator_ba se_funcs.h:68,
            from C:/Dev-Cpp/include/c++/bits/stl_algobase.h: 74,
            from C:/Dev-Cpp/include/c++/memory:54,
            from C:/Dev-Cpp/include/c++/string:48,
            from C:/Dev-Cpp/include/c++/bits/localefwd.h:49,
            from C:/Dev-Cpp/include/c++/ios:48,
            from C:/Dev-Cpp/include/c++/ostream:45,
            from C:/Dev-Cpp/include/c++/iostream:45,
            from main.cpp:1:
            C:/Dev-Cpp/include/c++/bits/concept_check.h :40:28: bits/c++config.h: No such file or directory
            In file included from C:/Dev-Cpp/include/c++/bits/stl_alloc.h:86,
            from C:/Dev-Cpp/include/c++/memory:55,
            from C:/Dev-Cpp/include/c++/string:48,

            from C:/Dev-Cpp/include/c++/bits/localefwd.h:49,
            from C:/Dev-Cpp/include/c++/ios:48,
            from C:/Dev-Cpp/include/c++/ostream:45,
            from C:/Dev-Cpp/include/c++/iostream:45,
            from main.cpp:1:
            C:/Dev-Cpp/include/c++/bits/stl_threads.h:5 2:23: bits/gthr.h: No such file or directory
            In file included from C:/Dev-Cpp/include/c++/bits/stl_alloc.h:86,
            from C:/Dev-Cpp/include/c++/memory:55,
            from C:/Dev-Cpp/include/c++/string:48,
            from C:/Dev-Cpp/include/c++/bits/localefwd.h:49,
            from C:/Dev-Cpp/include/c++/ios:48,
            from C:/Dev-Cpp/include/c++/ostream:45,
            from C:/Dev-Cpp/include/c++/iostream:45,
            from main.cpp:1:

            C:/Dev-Cpp/include/c++/bits/stl_threads.h: At global scope:
            C:/Dev-Cpp/include/c++/bits/stl_threads.h:6 9: '__gthread_mute x_t' is used as a
            type, but is not defined as a type.
            C:/Dev-Cpp/include/c++/bits/stl_threads.h:7 9:2: #error __GTHREAD_MUTEX _INIT or __GTHREAD_MUTEX _INIT_FUNCTION should be defined by gthr.h abstraction layer, report problem to libstdc++@gcc.g nu.org.
            C:/Dev-Cpp/include/c++/bits/stl_threads.h: In member function `void
            std::_Refcount_ Base::_M_incr() ':
            C:/Dev-Cpp/include/c++/bits/stl_threads.h:8 6: `_M_ref_count_l ock' undeclared
            (first use this function)
            C:/Dev-Cpp/include/c++/bits/stl_threads.h:8 6: `__gthread_mute x_lock' undeclared
            (first use this function)
            C:/Dev-Cpp/include/c++/bits/stl_threads.h:8 8: `__gthread_mute x_unlock'
            undeclared (first use this function)
            C:/Dev-Cpp/include/c++/bits/stl_threads.h: At global scope:
            C:/Dev-Cpp/include/c++/bits/stl_threads.h:1 58: '__gthread_mute x_t' is used as a
            type, but is not defined as a type.
            C:/Dev-Cpp/include/c++/bits/stl_threads.h: In member function `void
            std::_STL_mutex _lock::_M_acqui re_lock()':
            C:/Dev-Cpp/include/c++/bits/stl_threads.h:1 92: `_M_lock' undeclared (first use
            this function)

            In file included from C:/Dev-Cpp/include/c++/memory:55,
            from C:/Dev-Cpp/include/c++/string:48,
            from C:/Dev-Cpp/include/c++/bits/localefwd.h:49,
            from C:/Dev-Cpp/include/c++/ios:48,
            from C:/Dev-Cpp/include/c++/ostream:45,
            from C:/Dev-Cpp/include/c++/iostream:45,

            from main.cpp:1:
            C:/Dev-Cpp/include/c++/bits/stl_alloc.h: At global scope:
            C:/Dev-Cpp/include/c++/bits/stl_alloc.h:575 : syntax error before `;' token
            C:/Dev-Cpp/include/c++/bits/stl_alloc.h:575 : confused by earlier errors, bailing out

            make.exe: *** [main.o] Error 1

            Execution terminated

            Comment

            • weaknessforcats
              Recognized Expert Expert
              • Mar 2007
              • 9214

              #7
              This code:
              Originally posted by Redmoon
              cout<<Hello world!!!<<end1;
              should be:
              [code=cpp]
              cout<<"Hello world!!!"<<end1 ;
              [/code]

              You need quotation marks on each end of your literals.

              Comment

              • gzeng
                New Member
                • Mar 2007
                • 7

                #8
                First of all, the cout statement can not be compiled. Without puting the string into double quotes " ", the compilor will translate it as a variable. Yet, it is not defined. Secondly, Visual Studio 2005 did understant system.



                Originally posted by Redmoon
                This is my second post and still am unable to understand why this simplest program cannot compile and run for me. I am not so understanding to much of anything but this is my real interest, learning c++. Here is my code. I have followed my tutoring book and comes out with errors and then execution aborts.

                Code:
                #include <iostream>
                #include <stdlib.h>
                
                int main(int argc, char *argv[])
                {
                cout<<Hello world.<<endl;
                  
                  system("PAUSE");	
                  return 0;
                }
                Sorry in advance for wasting peoples time. I want to learn.

                Comment

                • sherbert
                  New Member
                  • Oct 2007
                  • 1

                  #9
                  right..

                  in the first bit, how come you have all that stuff in the brackets of int main?

                  you only need int main() then the { } brackets
                  cout<<Hello world.<<endl; for that bit, you need qoutation marks on the hello world

                  try copying and pasting this code:-

                  Code:
                  #include <iostream.h>
                  #include <stdlib.h>
                  
                  int main()
                  {
                        cout << "Hello world!" << endl;
                  
                        system("PAUSE");
                        return 0;
                  }
                  note: when you past it to the compiler, remove the blue 1,2,3,4,5,6,7,8 ,9 and 10 numbers before trying to compile or it wont work..

                  Comment

                  • oler1s
                    Recognized Expert Contributor
                    • Aug 2007
                    • 671

                    #10
                    Sherbert, you dug up an old threat. Moreover, you have a limited understanding of C and C++ and are making mistakes that reflect your limited knowledge.

                    The "stuff" inside the main would be arguments, and for main, the two arguments are used to contain the command line arguments passed to the program. It is acceptable to use main() without the arguments when you don't care for the command line arguments. There are only two forms of main that are acceptable: int main() and int main(int, char**). Now you know about the second form.

                    Furthermore, you need to buy a recent C++ book, becaus <iostream.h> and <stdlib.h> are Pre-1999 C++ standard header forms. For all standard libraries, there is no .h. C headers have a c prefixed to them.

                    Hence, you should have <iostream> and <cstdlib>. Furthermore, everything in the standard library is in the std namespace. So either qualify cout, endl, and system with std:: or add a using namespace std; directive.

                    Comment

                    Working...