Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. can someone write a simple programm for me it should just take a minute

can someone write a simple programm for me it should just take a minute

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
11 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J jaapdeboer

    Hello, I have a problem with the .exe's that I make. I open them and they close very fast so you can hardly read it or not. I asked this question a while ago but now I ask if one of you would write the programm "hello world" with the getch() command because that's what they advised me but I have no Idea how. n00b Thomas

    D Offline
    D Offline
    Diddy
    wrote on last edited by
    #2

    Like this: #include int main(...) { // your program here getch(); return 0; }

    J 1 Reply Last reply
    0
    • D Diddy

      Like this: #include int main(...) { // your program here getch(); return 0; }

      J Offline
      J Offline
      jaapdeboer
      wrote on last edited by
      #3

      this is what I did and when I try to compile now he gives an error #include #include //I thought I needed this one as well int main() { cout << "hello world"; getch(); return 0; }

      M D 2 Replies Last reply
      0
      • J jaapdeboer

        this is what I did and when I try to compile now he gives an error #include #include //I thought I needed this one as well int main() { cout << "hello world"; getch(); return 0; }

        M Offline
        M Offline
        Michael P Butler
        wrote on last edited by
        #4

        What is the compile error you get? The program in VS6 (generated console app wizard) should be as simple as #include #include int main(int argc, char* argv[]) { printf("Hello World!\n"); getch(); return 0; } Michael

        1 Reply Last reply
        0
        • J jaapdeboer

          this is what I did and when I try to compile now he gives an error #include #include //I thought I needed this one as well int main() { cout << "hello world"; getch(); return 0; }

          D Offline
          D Offline
          Diddy
          wrote on last edited by
          #5

          Tick the "do not treat <'s as HTML tags" box so we can see what you're including.

          J 1 Reply Last reply
          0
          • D Diddy

            Tick the "do not treat <'s as HTML tags" box so we can see what you're including.

            J Offline
            J Offline
            jaapdeboer
            wrote on last edited by
            #6

            #include conio.h #include iostream.h void main (void) { cout << "Hello World!\n"; getch(); // If I use return 0; there comes an error } Thomas

            D D 2 Replies Last reply
            0
            • J jaapdeboer

              #include conio.h #include iostream.h void main (void) { cout << "Hello World!\n"; getch(); // If I use return 0; there comes an error } Thomas

              D Offline
              D Offline
              Dev578
              wrote on last edited by
              #7

              "return 0;" gives you an error because void functions return no values.

              1 Reply Last reply
              0
              • J jaapdeboer

                #include conio.h #include iostream.h void main (void) { cout << "Hello World!\n"; getch(); // If I use return 0; there comes an error } Thomas

                D Offline
                D Offline
                Diddy
                wrote on last edited by
                #8

                Your signature for main is strictly wrong - should be int main(int argc, char* argv[]) Then you return an int - ie 0 or anything else u want

                J 1 Reply Last reply
                0
                • D Diddy

                  Your signature for main is strictly wrong - should be int main(int argc, char* argv[]) Then you return an int - ie 0 or anything else u want

                  J Offline
                  J Offline
                  jaapdeboer
                  wrote on last edited by
                  #9

                  In the book that I hired from the library and another one that I have at home both say this: #include iostream.h void main(void) { cout << "hello world"; } The problem is they used to work but know I can only open them in DOS that's not a problem for me but if I want to mail someone else my work and they don't know how to use DOS then it's a little problem. Thomas

                  N I 2 Replies Last reply
                  0
                  • J jaapdeboer

                    In the book that I hired from the library and another one that I have at home both say this: #include iostream.h void main(void) { cout << "hello world"; } The problem is they used to work but know I can only open them in DOS that's not a problem for me but if I want to mail someone else my work and they don't know how to use DOS then it's a little problem. Thomas

                    N Offline
                    N Offline
                    Nick Parker
                    wrote on last edited by
                    #10

                    jaapdeboer wrote: The problem is they used to work but know I can only open them in DOS that's not a problem for me but if I want to mail someone else my work and they don't know how to use DOS then it's a little problem. The executable itself will launch inside a command prompt as you have written it. If you want a windowed application you will need to write it as such. - Nick Parker
                      My Blog

                    1 Reply Last reply
                    0
                    • J jaapdeboer

                      In the book that I hired from the library and another one that I have at home both say this: #include iostream.h void main(void) { cout << "hello world"; } The problem is they used to work but know I can only open them in DOS that's not a problem for me but if I want to mail someone else my work and they don't know how to use DOS then it's a little problem. Thomas

                      I Offline
                      I Offline
                      Ian Darling
                      wrote on last edited by
                      #11

                      jaapdeboer wrote: In the book that I hired from the library and another one that I have at home both say this: #include iostream.h void main(void) { cout << "hello world"; } Not being funny, but those books are either full of crap, or seriously outdated (by at least 5 or 6 years). main returning void is non-standard (it can accept a void type for the parameter list). main does not require a return, however if it is missed, then there is an implicit return 0 included.


                      Ian Darling "The different versions of the UN*X brand operating system are numbered in a logical sequence: 5, 6, 7, 2, 2.9, 3, 4.0, III, 4.1, V, 4.2, V.2, and 4.3" - Alan Filipski

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups