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. programming C in Visual C++ express edition.

programming C in Visual C++ express edition.

Scheduled Pinned Locked Moved C / C++ / MFC
c++questiondelphihardware
23 Posts 7 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.
  • Richard Andrew x64R Richard Andrew x64

    have you tried:

    #include "stdio.h"

    C Offline
    C Offline
    cavemen
    wrote on last edited by
    #3

    yes i did it doesn't add the header gives out an error message before i run my hello world program

    Richard Andrew x64R 1 Reply Last reply
    0
    • C cavemen

      yes i did it doesn't add the header gives out an error message before i run my hello world program

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #4

      So what is the error message?

      C 1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        So what is the error message?

        C Offline
        C Offline
        cavemen
        wrote on last edited by
        #5

        Just tells me that there are errors during compilation. and displyas a built-in hello world example result (when you choose that you want to build c++ console it already writes a c++ hello world program using iostream.h)

        Richard Andrew x64R 1 Reply Last reply
        0
        • C cavemen

          Just tells me that there are errors during compilation. and displyas a built-in hello world example result (when you choose that you want to build c++ console it already writes a c++ hello world program using iostream.h)

          Richard Andrew x64R Offline
          Richard Andrew x64R Offline
          Richard Andrew x64
          wrote on last edited by
          #6

          Those error messages are telling you what's wrong. If you want help, you must tell us what the error messages say.

          C 1 Reply Last reply
          0
          • C cavemen

            I need to learn C because I am about to develop microcontroller projects that use C. I got books about C. I might need C++ in the future, but for totally different things. Is it possible to use stdio.h in MS Visual C++? How do I do so? How do I keep command prompt applications from closing the console after they are done playing? If i want to see my "hello world" or some variable number output. Is Keil uVision the only compiler to suit ARM microcontrollers? Maybe I need something like Borland compiler so I can write ARM code and PC code on the same compiler? Thank you.

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #7

            if you want C, not C++, then make sure your source file has extension .c rather than .cpp For a simple C app, you can delete most if not all pre-generated file content in Visual. A console app will clause automatically when main returns (unless ran from inside Visual Studio). You can change that by ending main on (pseudo-code!):

            Console.Write("Hit ENTER to terminate");
            Console.ReadKey();

            There must be dozens of compilers running on PC and targeting ARM. Some vendors offer hundreds of combinations (all kinds of languages, all kinds of targets). Not sure Borland is one of them; personally I don't see an advantage, I've done C for many targets (choosing the best compiler for each of them), and for PC (using Visual Studio). :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


            Nil Volentibus Arduum


            1 Reply Last reply
            0
            • Richard Andrew x64R Richard Andrew x64

              Those error messages are telling you what's wrong. If you want help, you must tell us what the error messages say.

              C Offline
              C Offline
              cavemen
              wrote on last edited by
              #8

              no maybe i should switch to a different compiler visual studio professional is very big too big for my computer

              C D 2 Replies Last reply
              0
              • C cavemen

                no maybe i should switch to a different compiler visual studio professional is very big too big for my computer

                C Offline
                C Offline
                Cedric Moonen
                wrote on last edited by
                #9

                cavemen wrote:

                no maybe i should switch to a different compiler visual studio professional is very big too big for my computer

                :doh: You know that you will still get these errors with another compiler, since these are compilation errors and they won't magically disappear if you use another compiler.

                Cédric Moonen Software developer
                Charting control [v3.0] OpenGL game tutorial in C++

                1 Reply Last reply
                0
                • C cavemen

                  I need to learn C because I am about to develop microcontroller projects that use C. I got books about C. I might need C++ in the future, but for totally different things. Is it possible to use stdio.h in MS Visual C++? How do I do so? How do I keep command prompt applications from closing the console after they are done playing? If i want to see my "hello world" or some variable number output. Is Keil uVision the only compiler to suit ARM microcontrollers? Maybe I need something like Borland compiler so I can write ARM code and PC code on the same compiler? Thank you.

                  S Offline
                  S Offline
                  sunlin7
                  wrote on last edited by
                  #10

                  You need to add the sdk information to your Visual Studio. e.g: add "D:\Program Files\Microsoft SDKs\Windows\v6.0A\bin" to "Executable files", add "D:\Program Files\Microsoft SDKs\Windows\v6.0A\Include" to "Include files", add "D:\Program Files\Microsoft SDKs\Windows\v6.0A\lib" to "Libraray files", ... Please check these settings of Visual Studio on your machine.

                  C 1 Reply Last reply
                  0
                  • C cavemen

                    no maybe i should switch to a different compiler visual studio professional is very big too big for my computer

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #11

                    Given this and your other comments, maybe you should hold off on the 'microcontroller projects' until you have a better understanding of development. Otherwise, you'll just end up frustrated.

                    "One man's wage rise is another man's price increase." - Harold Wilson

                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                    "Man who follows car will be exhausted." - Confucius

                    C 1 Reply Last reply
                    0
                    • C cavemen

                      I need to learn C because I am about to develop microcontroller projects that use C. I got books about C. I might need C++ in the future, but for totally different things. Is it possible to use stdio.h in MS Visual C++? How do I do so? How do I keep command prompt applications from closing the console after they are done playing? If i want to see my "hello world" or some variable number output. Is Keil uVision the only compiler to suit ARM microcontrollers? Maybe I need something like Borland compiler so I can write ARM code and PC code on the same compiler? Thank you.

                      A Offline
                      A Offline
                      Aescleal
                      wrote on last edited by
                      #12

                      Yes you can use stdio.h - VC++ has been a pretty C89 standard compliant C compiler since about 1997. It's unlikely to grow any C99 features in the short term though. Use CTRL+F5 to run your code - then the console window window won't close when the program exits. It'll just sit there with a "press any key to continue..." message. There are loads of compilers that support ARM. I've used gcc for developing on mobile phones and some of my collegues have used a couple of proprietary compilers as well. Doing a quick google for "ARM C compiler" gave me 8 relevant hits on the first page. Cheers, Ash

                      1 Reply Last reply
                      0
                      • D David Crow

                        Given this and your other comments, maybe you should hold off on the 'microcontroller projects' until you have a better understanding of development. Otherwise, you'll just end up frustrated.

                        "One man's wage rise is another man's price increase." - Harold Wilson

                        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                        "Man who follows car will be exhausted." - Confucius

                        C Offline
                        C Offline
                        cavemen
                        wrote on last edited by
                        #13

                        I am not talking about microcontrollers right now. I will get to that. Here is the question. So I have Microsoft Visual C++ Express edition and I am struggling to create a C console application. I am not sure how I ADD a stdio.h header and a main source file to accept the C code. I am sure it is possible, it is just that al defaults in VC++ are for C++ and object-oriented programs I won't need for a while. I can create a class. I can create a header file. I can't create a plain code file. I don't know what to type into the header file. Thank you.

                        D 1 Reply Last reply
                        0
                        • C cavemen

                          I am not talking about microcontrollers right now. I will get to that. Here is the question. So I have Microsoft Visual C++ Express edition and I am struggling to create a C console application. I am not sure how I ADD a stdio.h header and a main source file to accept the C code. I am sure it is possible, it is just that al defaults in VC++ are for C++ and object-oriented programs I won't need for a while. I can create a class. I can create a header file. I can't create a plain code file. I don't know what to type into the header file. Thank you.

                          D Offline
                          D Offline
                          David Crow
                          wrote on last edited by
                          #14

                          cavemen wrote:

                          So I have Microsoft Visual C++ Express edition and I am struggling to create a C console application. I am not sure how I ADD a stdio.h header and a main source file to accept the C code.

                          From the File menu, click New then Project. In the New Project dialog, select Win32 Console Application. Give the project a name, and verify the Location. No need for a Solution. In the Application Wizard dialog, just accept the defaults. In the Solution Explorer pane on the left, right-click Source Files and select Add then New Item. Add a C++ file, and give it a name. That file should show up in the left pane under Source Files. Double-click it to start editing. Add something like the following to it:

                          #include <stdio.h>

                          void main( void )
                          {
                          printf("Hello World\n");
                          }

                          "One man's wage rise is another man's price increase." - Harold Wilson

                          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                          "Man who follows car will be exhausted." - Confucius

                          C 1 Reply Last reply
                          0
                          • D David Crow

                            cavemen wrote:

                            So I have Microsoft Visual C++ Express edition and I am struggling to create a C console application. I am not sure how I ADD a stdio.h header and a main source file to accept the C code.

                            From the File menu, click New then Project. In the New Project dialog, select Win32 Console Application. Give the project a name, and verify the Location. No need for a Solution. In the Application Wizard dialog, just accept the defaults. In the Solution Explorer pane on the left, right-click Source Files and select Add then New Item. Add a C++ file, and give it a name. That file should show up in the left pane under Source Files. Double-click it to start editing. Add something like the following to it:

                            #include <stdio.h>

                            void main( void )
                            {
                            printf("Hello World\n");
                            }

                            "One man's wage rise is another man's price increase." - Harold Wilson

                            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                            "Man who follows car will be exhausted." - Confucius

                            C Offline
                            C Offline
                            cavemen
                            wrote on last edited by
                            #15

                            Thank you. But when I try to run the empty project it tells me that it cannot find a file path to my project "lesson1\debug\lesson1.exe" (lesson1 is my first project name) this message pops out, nomatter where I create it, the desktop or the default vc++ folder in my documents.

                            D 1 Reply Last reply
                            0
                            • S sunlin7

                              You need to add the sdk information to your Visual Studio. e.g: add "D:\Program Files\Microsoft SDKs\Windows\v6.0A\bin" to "Executable files", add "D:\Program Files\Microsoft SDKs\Windows\v6.0A\Include" to "Include files", add "D:\Program Files\Microsoft SDKs\Windows\v6.0A\lib" to "Libraray files", ... Please check these settings of Visual Studio on your machine.

                              C Offline
                              C Offline
                              cavemen
                              wrote on last edited by
                              #16

                              not sure where i do that

                              S 1 Reply Last reply
                              0
                              • C cavemen

                                Thank you. But when I try to run the empty project it tells me that it cannot find a file path to my project "lesson1\debug\lesson1.exe" (lesson1 is my first project name) this message pops out, nomatter where I create it, the desktop or the default vc++ folder in my documents.

                                D Offline
                                D Offline
                                David Crow
                                wrote on last edited by
                                #17

                                cavemen wrote:

                                But when I try to run the empty project it tells me that it cannot find a file path to my project...

                                Have you tried Googling for the error number/message?

                                "One man's wage rise is another man's price increase." - Harold Wilson

                                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                                "Man who follows car will be exhausted." - Confucius

                                C 1 Reply Last reply
                                0
                                • D David Crow

                                  cavemen wrote:

                                  But when I try to run the empty project it tells me that it cannot find a file path to my project...

                                  Have you tried Googling for the error number/message?

                                  "One man's wage rise is another man's price increase." - Harold Wilson

                                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                                  "Man who follows car will be exhausted." - Confucius

                                  C Offline
                                  C Offline
                                  cavemen
                                  wrote on last edited by
                                  #18

                                  I did. I had to hit "build solution" before running it. However it doesn't want to compile the #include void main( void ) { printf("Hello World\n"); } The building information in "Output" tells me that there is one error the compiler had to skip somewhere.

                                  D C 2 Replies Last reply
                                  0
                                  • C cavemen

                                    I did. I had to hit "build solution" before running it. However it doesn't want to compile the #include void main( void ) { printf("Hello World\n"); } The building information in "Output" tells me that there is one error the compiler had to skip somewhere.

                                    D Offline
                                    D Offline
                                    David Crow
                                    wrote on last edited by
                                    #19

                                    cavemen wrote:

                                    The building information in "Output" tells me that there is one error...

                                    What error? What line?

                                    "One man's wage rise is another man's price increase." - Harold Wilson

                                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                                    "Man who follows car will be exhausted." - Confucius

                                    C 1 Reply Last reply
                                    0
                                    • D David Crow

                                      cavemen wrote:

                                      The building information in "Output" tells me that there is one error...

                                      What error? What line?

                                      "One man's wage rise is another man's price increase." - Harold Wilson

                                      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                                      "Man who follows car will be exhausted." - Confucius

                                      C Offline
                                      C Offline
                                      cavemen
                                      wrote on last edited by
                                      #20

                                      ------ Build started: Project: Lesson1_2, Configuration: Debug Win32 ------ Compiling... Lesson1_2.cpp Hello world.cpp c:\documents and settings\safeuser\my documents\visual studio 2008\projects\lesson1_2\lesson1_2\hello world.cpp(1) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? Generating Code... Build log was saved at "file://c:\Documents and Settings\SafeUser\My Documents\Visual Studio 2008\Projects\Lesson1_2\Lesson1_2\Debug\BuildLog.htm" Lesson1_2 - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

                                      D 1 Reply Last reply
                                      0
                                      • C cavemen

                                        ------ Build started: Project: Lesson1_2, Configuration: Debug Win32 ------ Compiling... Lesson1_2.cpp Hello world.cpp c:\documents and settings\safeuser\my documents\visual studio 2008\projects\lesson1_2\lesson1_2\hello world.cpp(1) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? Generating Code... Build log was saved at "file://c:\Documents and Settings\SafeUser\My Documents\Visual Studio 2008\Projects\Lesson1_2\Lesson1_2\Debug\BuildLog.htm" Lesson1_2 - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

                                        D Offline
                                        D Offline
                                        David Crow
                                        wrote on last edited by
                                        #21

                                        cavemen wrote:

                                        c:\documents and settings\safeuser\my documents\visual studio 2008\projects\lesson1_2\lesson1_2\hello world.cpp(1) : fatal error C1010: unexpected end of file while looking for precompiled header.

                                        See here.

                                        "One man's wage rise is another man's price increase." - Harold Wilson

                                        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                                        "Man who follows car will be exhausted." - Confucius

                                        1 Reply Last reply
                                        0
                                        • C cavemen

                                          not sure where i do that

                                          S Offline
                                          S Offline
                                          sunlin7
                                          wrote on last edited by
                                          #22

                                          You need run VisualStudio, then choose the follow options begin from "Tools" menu: "Tools->Options...->Project and solutions->VC++ Directories" you can set the executable/libraray/include directories now.

                                          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