Is there an End command equivalent in C++ - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Is there an End command equivalent in C++

I am writing a program to do greatest common factor. It works great(C++ is SOOOOO much faster than Qbasic). I am putting in a function called delay. Its contents are below

int delay()
{
printf("
Press enter to continue");
scanf ("%d", temp);
cout << temp;
}

temp is just a variable I made up(yes I declared it at the top)

Now when I run it, I can press enter over and over and over
it does nothing

Is there a qbasic "END" equivalent in C++

--Joey


Comments

  • the extent of my C++ knowledge is hour 1 of teach yourself c in 24 hours but try
    return 0;
    or
    exit(0);

    I don't know how close C and C++ santax are but let me know if it werx


    : I am writing a program to do greatest common factor. It works great(C++ is SOOOOO much faster than Qbasic). I am putting in a function called delay. Its contents are below
    :
    : int delay()
    : {
    : printf("
    Press enter to continue");
    : scanf ("%d", temp);
    : cout << temp;
    : }
    :
    : temp is just a variable I made up(yes I declared it at the top)
    :
    : Now when I run it, I can press enter over and over and over
    : it does nothing
    :
    : Is there a qbasic "END" equivalent in C++
    :
    : --Joey
    :



  • what you are doing by using ther scanf function is asking the user to enter something. Run you program and instead of hitting enter type a number or something and then hit enter. it will exit. By say Press enter to continue and then putting a scanf you want the user to enter something. YOu need a pause function or something. I am sure there is a library with one. YOu are trying to have the program pause not let the user enter something and that is what scanf is.
    Vince



    : the extent of my C++ knowledge is hour 1 of teach yourself c in 24 hours but try
    : return 0;
    : or
    : exit(0);
    :
    : I don't know how close C and C++ santax are but let me know if it werx
    :
    :
    : : I am writing a program to do greatest common factor. It works great(C++ is SOOOOO much faster than Qbasic). I am putting in a function called delay. Its contents are below
    : :
    : : int delay()
    : : {
    : : printf("
    Press enter to continue");
    : : scanf ("%d", temp);
    : : cout << temp;
    : : }
    : :
    : : temp is just a variable I made up(yes I declared it at the top)
    : :
    : : Now when I run it, I can press enter over and over and over
    : : it does nothing
    : :
    : : Is there a qbasic "END" equivalent in C++
    : :
    : : --Joey
    : :
    :
    :



  • Simply chang into:

    int delay()
    {
    printf("
    Press enter to continue");
    // scanf ("%d", temp);
    // cout << temp;
    getch()
    }




Sign In or Register to comment.