My First Line....

Hello, I have this code and I am very confused with it,
The online resources say that this code should work but it does NOT
on Visual Basic C++ Express Beta 2

My .ccp is named DEDLOC.cpp and so are other project names...

This is the Code:
for
stdafx.cpp:
_______________________________________________________________________

// stdafx.cpp : source file that includes just the standard includes
// DEDLOC.pch will the the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include
"stdafx.h"

// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

________________________________________________________________________

for
stdafx.h:

// stdafx.h : included file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently


#pragma once

#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers

#include <stdio.h>

#include <tchar.h>

// TODO: reference additional headers your program requires here

__________________________________________________________________________


for DEDLOC.cpp:

// operating with variables

#include <stdafx.h>

int main ()
{
   // declaring variables:
   int a, b;
   int result;

   // process:
   a = 5;
   b = 2;
   a = a +1;

   // print out the result:
   cout << result;

   // terminate the program:
   return 0;
}

___________________________________________________________________________

Thank You for
any help!

P.S.
I am a beginner that just started so
please be kind!



Answer this question

My First Line....

  • Sunil.Waghmare

    Hi,

    If your using Visual studio then instead of running your program in the conventional F5 - Start Debugging with Ctrl+F5 - Start without Debugging. Upon executing your program, a halt operation would be generated for you by the system so that your console would not disappear...

     

     

    cheers,

    Paul June A. Domag



  • Jordy

    Hmmmm, I see you've got main() as your entry point.  You're writing a console application then   If that's the case, then your programme is running, and is producing output, but in a console window.  Now, because your programme terminates, that window is being closed.  Put a getchar() before the closing brace of your code so that the programme waits for a key press before terminating.


  • Spacetime

    Okay,
    Your problem is that the console doesn't halt for you to, well do anything, for example read it.For a free compiler goto bloodshed.net.  Theirs is the best GUI compiler for simple programs.  Rewrite it like so.

    #include <iostream>

    using namespace std;
    int main()
    {
        //Your Code
        System("PAUSE");
        return 0;
    }

    The "System("Pause")" tell the command console to halt until there is a keypress.  After press any key, the console will close.

    This will help.


  • MobilTech

    well, my purpose is simple,
    make a VERY simple program for Hobby...
    And I wish to know the problem.....
    The computer seems NOT to tell me WHAT is wrong....
    Well, maybe I am not noticing it, but.....

    But thank you for a reply!

  • Johan van Toll

    Before getting into the code, what is the purpose of learning C++   If you are a beginner with no development experience who is looking to develop windows and web apps, don't learn C++, learn C# (or VB.NET).  Both are FAR FAR easier to use, and you'll have running running applications literally in minutes.

    I can't answer why your app isn't working since you don't provide the specific error.  However, I wouldn't even try to learn C/C++ unless you really need it for work/school.

    Best of luck,
    Josh Lindenmuth

  • BlueAce

    hello, i am back,
    sorry, I haven't paid attention to this forum...
    Well, now I know that it is a consol program...
    I just think I was dumb because I thought that
    the console program was a windows form program...
    Now that I have more knowledge here, I started on
    Windows Forms.

    Please help me out there too, you guys are awesom at helping!
    Well, it is in Visual Basic but I think it only makes a little difference...

    Thank You all!
    Keehun Nam

  • Vincent Blain

    thank you,
    I've always wondered
    how to halt the console


  • Suscuaja

    Hi,

    Your code posting seems right to my eye. What exactly do you mean that it doesn't work Did it generate some kind of error Or you couldn't see anything If so try running the program with ctrl+F5 rather that just F5...

     

     

     

    cheers,

    Paul June A. Domag



  • hehemouse

    @KN1123:

    You already read about the hint: Read a book!
    I agree to it.

    But some other hints:
    1. You forgot to inlcude files to use the std streams. #incluse <iostream>
    2. To use cout without a namespace prefix, you have to put a using namespace std; at the head of main.

  • My First Line....