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. c programming

c programming

Scheduled Pinned Locked Moved C / C++ / MFC
5 Posts 5 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.
  • M Offline
    M Offline
    Member_14608313
    wrote on last edited by
    #1

    I want to get a positive integer from the user.

    P D V CPalliniC 4 Replies Last reply
    0
    • M Member_14608313

      I want to get a positive integer from the user.

      P Offline
      P Offline
      phil o
      wrote on last edited by
      #2

      "I want" is not a question.

      "Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."

      1 Reply Last reply
      0
      • M Member_14608313

        I want to get a positive integer from the user.

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        There's only about a couple dozen different ways to do that, depending on the application type you're writing and the context in which you're getting this input. Without a lot more detail about what you're doing, anything anyone replies with will be just guess work that will probably not work in your situation.

        Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
        Dave Kreskowiak

        1 Reply Last reply
        0
        • M Member_14608313

          I want to get a positive integer from the user.

          V Offline
          V Offline
          Victor Nijegorodov
          wrote on last edited by
          #4

          Do it! Good luck! :)

          1 Reply Last reply
          0
          • M Member_14608313

            I want to get a positive integer from the user.

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            You could start from

            #include int main()
            {
            int i;
            for (;;)
            {
            printf("please enter a positive integer\n");
            if ( scanf("%d", &i) == 1 && i > 0 ) break;
            }
            printf("you entered %d, a good one\n", i);
            return 0;
            }

            and then find a better way...

            In testa che avete, signor di Ceprano?

            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