Menu

RT: Testing: A Simple Hello World Program

Wayne Keen
2004-03-09
2012-09-26
<< < 1 2 3 4 .. 6 > >> (Page 2 of 6)
  • Nobody/Anonymous

    well thanks for the help. i did the full uninstall. copied in the code above and it worked fine, i will be useing the pause command in the bottom line of all my test programs. i am assumeing that is what makes the window stick around
    wow i hate to post anonymously. ill haveta register soon.

    well thanks for the help man.

    shadowrifty

     
  • Nobody/Anonymous

    Wayne - shouldn't you use "#include <cstdlib> "instead of "#include <stdlib.h>"?

    luke

     
    • Wayne Keen

      Wayne Keen - 2004-05-01

      Luke,

      Yes, in general that is true.  However, I tried to write the example in such a way as to get it to work with 4 series of Dev, which uses the earlier version of the GCC compiler.

      Wayne

       
  • Nobody/Anonymous

    DevC++ 5 beta 8.10 Windows XP prof.

    code:
    #include<iostream>
    #include<stdlib.h> //only needed if you are using Dev 4 family
    using namespace std; //where the names are - like cout!

    int main(void)
    {
    cout << "This is what that putz Wayne said to do!\n";
    system("pause"); //keep the window open if running from Dev
    return 0;
    }

    Compiler log:

    Compiler: Default compiler
    Building Makefile: "D:\Programme\Dev-Cpp\progs\Projekt1\Makefile.win"
    Fhrt  make... aus
    make.exe -f "D:\Programme\Dev-Cpp\progs\Projekt1\Makefile.win" all
    make.exe: Circular test <- test.o dependency dropped.

    g++.exe -c test -o test.o -I"D:/Programme/Dev-Cpp/include/c++"  -I"D:/Programme/Dev-Cpp/include/c++/mingw32"  -I"D:/Programme/Dev-Cpp/include/c++/backward"  -I"D:/Programme/Dev-Cpp/include" 

    Zugriff verweigert

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

    Ausfhrung beendet

    I am logged in as admin and there are no restrictions on the folders. thanks for helping! b

     
  • Nobody/Anonymous

    hallo lute
    I have the same probleme as the  volks in this topic,

    include <iostream>

    using namespace std;

    int main (int argc, char *argv[])
    {
      cout << "Hello World!" << endl;
      cout << "Press ENTER to continue..." << endl;
      cin.get();
      return 0;
    }

    this are the errors:
     
    [Resource error] no resources
    C:\Dev-Cpp\Makefile.win [Build Error]  [Project17_private.res] Error 1

    compiler log
    Compiler: Default compiler
    Building Makefile: "C:\Dev-Cpp\Makefile.win"
    Bezig met uitvoeren van  make...
    make.exe -f "C:\Dev-Cpp\Makefile.win" all
    g++.exe -c Naamloos17.cpp -o Naamloos17.o -I"C:/Dev-Cpp/include/c++/3.3.1"  -I"C:/Dev-Cpp/include/c++/3.3.1/mingw32"  -I"C:/Dev-Cpp/include/c++/3.3.1/backward"  -I"C:/Dev-Cpp/lib/gcc-lib/mingw32/3.3.1/include"  -I"C:/Dev-Cpp/include"  

    windres.exe -i Project17_private.rc -I rc -o Project17_private.res -O coff

    windres.exe: no resources

    make.exe: *** [Project17_private.res] Error 1

    Uitvoering voltooid

    Help!!! I don''t know what it means even when i try other scripts I have the same problem
    Running dev-c++ 4.9.9.0
    greetings erik

     
  • Nobody/Anonymous

    Erik:

    I think you simply forgot to add the required "#" before the include statement...namely:

    #include <iostream>

    using namespace std;

    int main (int argc, char *argv[])
    {
    cout << "Hello World!" << endl;
    cout << "Press ENTER to continue..." << endl;
    cin.get();
    return 0;
    }

    That should compile without any problem.  Good luck.

     
  • Nobody/Anonymous

    Hi! I tried  this helloworld (I'd made a copy) code but whatever I do, I always have this error message:

    error line 2  unable to run program file

    I tried many other codes but I'd always got the same message wath ever the line 2 contains

    I need help please!

     
  • Jim W.

    Jim W. - 2004-09-17

    This thread was started last March.  Since then some new resources have been posted.  Please look for the message entitled:

    --> THE FORUM FAQ - PLEASE READ FIRST <--

    This thread has also collected questions about a number of different problems, which can be confusing.  After reading the FAQ (and searching the Forum), start a new thread, if needed.

    -- Jim.

     
  • Nobody/Anonymous

    To Wayne:

    i am using Dev-C++ 5.0 beta 9 (4.9.9.1) (7.6 MB) with Mingw/GCC 3.3.1 & Windows XP SP2

    Compiler: Default compiler
    Executing g++.exe...
    g++.exe "C:\Documents and Settings\derek\Desktop\C++\abc.cpp" -o "C:\Documents and Settings\derek\Desktop\C++\abc.exe" -I"C:\Dev-Cpp\include\c++\3.3.1" -I"C:\Dev-Cpp\include\c++\3.3.1\mingw32" -I"C:\Dev-Cpp\include\c++\3.3.1\backward" -I"C:\Dev-Cpp\lib\gcc-lib\mingw32\3.3.1\include" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
    Execution terminated

    What is going on?

    and I can't Download Bloodshed C++ 4.9.8.0
    (i can't find it, there is only 4.9.9.1 download available

    ---Derek

     
  • Wayne Keen

    Wayne Keen - 2005-01-10

    Well, your program is stored on your desktop, which means it is in a path with spaces in it. Thats not a good idea.

    Also, is your installation of 4.9.9.1 a fresh installation, or was there any previous version of Dev on the computer?

    Wayne

     
  • Nobody/Anonymous

    to Wayne:
    Program is in My Document
    File is in A folder that stored in Desktop

    and i don't sure that yes or no...

    i think is only 1(my opinion) because in 2 weeks before, i have installed it... but 1 day later, i uninstalled it....

    so i can't make sure that have or haven't

    Derek

     
  • Wayne Keen

    Wayne Keen - 2005-01-10

    Putting your source file in a directory like this is a bad idea - spaces will cause issues:

    C:\Documents and Settings\derek\Desktop\C++\abc.cpp

    Now, I recommend you follow the directions in the thread "The Forum FAQ - Please Read First" for doing a clean uninstall - follow them carefully. Fully clean Dev from your machine. Then reinstall and try again.

    Wayne

     
  • Nobody/Anonymous

    then what do you recommended??
    What directory is the best???

    --Derek

     
  • Nobody/Anonymous

    Thx Wayne

    I can do it now..Thx~

    --Derek

     
  • Wayne Keen

    Wayne Keen - 2005-01-10

    I keep mine in

    c:\mycstuff

    The key is to not have spaces in the path to either your code, or Dev itself, so you need to avoid places like

    "My Documents"
    "Program Files"
    Your desktop

    Persoanlly, I always let Dev install where it wants, usually

    c:\dev-cpp

    Wayne

    Wayne

     
  • Nobody/Anonymous

    On my Sony the D drive has all the room, so I use D:\DevCpp

    Ulrike

     
    • Wayne Keen

      Wayne Keen - 2005-01-10

      As long as its a physical drive on your machine, that should be fine.

      Make sure you nuke your past installation thoroughly, including removing all associated directories / hidden configuration files

      Wayne

       
  • Nobody/Anonymous

    to Wayne:

    I am trying about another version of Hello World
    , but there is some problem
    can u tell me why?

    // HelloWorld.cpp : Defines the entry point for the console application.
    //

    include "stdafx.h"

    include <iostream.h>

    //Function prototypes
    bool SayHello (char* szTo,int nCalc);
    void SayGoodbye ();
    //Constants

    define NUMERO_UNO 1

    const char MY_FRIEND="Myfriend!";
    int main (int argc,char
    argv[])
    {
    char szCpp="crazy C++!"; //Declare a variable.
    //Call a function with a Boolean result.
    if (SayHello (szCpp,2))
    {
    //Call a function with no result.
    SayGoodbye ();
    }
    return 0;
    }
    //Global function definitions
    //SayHello takes two parameters and returns a result.
    bool SayHello (char
    szTo , int nCalc)
    {
    //Use an iostream object for output.
    cout<<"Hello , "<<szTo<<"I'm Number"<<NUMBERO_UNO<<"programmer.\n";
    return (nCalc+ (nCalc*2))<(24/nCalc);
    }
    //SayGoodbye takes no parameters and returns no result.
    void SayGoodbye()
    {
    cout<<"Bye,"<<MY_FRIEND<<endl;
    }

    Compiler: Default compiler
    Executing g++.exe...
    g++.exe "C:\mycstuff\HW2.cpp" -o "C:\mycstuff\HW2.exe" -I"C:\Dev-Cpp\include\c++\3.3.1" -I"C:\Dev-Cpp\include\c++\3.3.1\mingw32" -I"C:\Dev-Cpp\include\c++\3.3.1\backward" -I"C:\Dev-Cpp\lib\gcc-lib\mingw32\3.3.1\include" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
    C:/mycstuff/HW2.cpp:3:20: stdafx.h: No such file or directory
    In file included from C:/Dev-Cpp/include/c++/3.3.1/backward/iostream.h:31,
    from C:/mycstuff/HW2.cpp:4:
    C:/Dev-Cpp/include/c++/3.3.1/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.
    C:/mycstuff/HW2.cpp: In function bool SayHello(char*, int)': C:/mycstuff/HW2.cpp:27: error:NUMBERO_UNO' undeclared (first use this
    function)
    C:/mycstuff/HW2.cpp:27: error: (Each undeclared identifier is reported only
    once for each function it appears in.)

    C:/mycstuff/HW2.cpp:34:2: warning: no newline at end of file

    Execution terminated

    --Derek

     
  • Wayne Keen

    Wayne Keen - 2005-01-11

    Is stdafx.x really in the local directory with your program, that is what the quotes in your include statement mean.

    Wayne

     
  • Stepho

    Stepho - 2005-01-11

    stdafx.h is a file generated by MS Visual C++, related to MFC.
    The example has probably been created with VC++...
    You can remove the include line.

    Also, at line 43 you have written NUMBERO_UNO instead of NUMERO_UNO.

    I also suggest that you change the deprecated
    #include <iostream.h>
    with
    #include <iostream>
    using namespace std;

    But I'm using version 4.9.9.1, I don't know if the last applies to your version too.

     
  • Nobody/Anonymous

    to Wayne:

    no
    I'm just looking at a book that teach Visual C++ 6.0

    to Stphane Ch.:
    I'm using version 4.9.9.1 too~

     
  • Nobody/Anonymous

    // HelloWorld.cpp : Defines the entry point for the console application.
    //

    include <iostream.h>

    //Function prototypes
    bool SayHello (char* szTo,int nCalc);
    void SayGoodbye ();
    //Constants

    define NUMERO_UNO 1

    const char MY_FRIEND="Myfriend!";
    int main (int argc,char
    argv[])
    {
    char szCpp="crazy C++!"; //Declare a variable.
    //Call a function with a Boolean result.
    if (SayHello (szCpp,2))
    {
    //Call a function with no result.
    SayGoodbye ();
    }
    return 0;
    }
    //Global function definitions
    //SayHello takes two parameters and returns a result.
    bool SayHello (char
    szTo , int nCalc)
    {
    //Use an iostream object for output.
    cout<<"Hello , "<<szTo<<"I'm Number"<<NUMERO_UNO<<"programmer.\n";
    return (nCalc+ (nCalc*2))<(24/nCalc);
    }
    //SayGoodbye takes no parameters and returns no result.
    void SayGoodbye()
    {
    cout<<"Bye,"<<MY_FRIEND<<endl;
    }

    new one

    Compiler: Default compiler
    Executing g++.exe...
    g++.exe "C:\mycstuff\HW2.cpp" -o "C:\mycstuff\HW2.exe" -I"C:\Dev-Cpp\include\c++\3.3.1" -I"C:\Dev-Cpp\include\c++\3.3.1\mingw32" -I"C:\Dev-Cpp\include\c++\3.3.1\backward" -I"C:\Dev-Cpp\lib\gcc-lib\mingw32\3.3.1\include" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
    In file included from C:/Dev-Cpp/include/c++/3.3.1/backward/iostream.h:31,
    from C:/mycstuff/HW2.cpp:3:
    C:/Dev-Cpp/include/c++/3.3.1/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.
    C:/mycstuff/HW2.cpp:33:2: warning: no newline at end of file

    Execution terminated
    Compilation successful

    but there is a question, why that it will not stop and it will close itself automatically ???

    ---Derek

     
  • Stepho

    Stepho - 2005-01-11

    The problem is explained in the FAQ. I don't know where exactly.

    But to answer you quickly (lunch time here ;-) ), this behaviour is normal, the console window exits when the program is finished.
    You can add the following line at the end of your main function :
    system("pause");

    (This requires "#include <cstdlib>" if my memory doesn't fail me)

     
  • Wayne Keen

    Wayne Keen - 2005-01-11

    "(This requires "#include <cstdlib>" if my memory doesn't fail me)"

    Not if one is using version 5, and has included iostream

    Wayne

     
  • Stepho

    Stepho - 2005-01-11

    Oh, good.

    Thanks Wayne :-)

     
<< < 1 2 3 4 .. 6 > >> (Page 2 of 6)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.