Thread: stopping some scanning

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    11

    stopping some scanning

    what is the best way to stop scanning from a for loop.
    i have a trigger that i have to use to stop the scanning but i am unsure how to use it.

    i have to scan a bunch of numbers into an array and use '00000' to stop the scanning of ints and move on, anyone help?
    thanks

  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    You could use break.
    Code:
    for(i=0;i<1000;i++){
    if(x==5){
    break;
    }
    //More code
    }
    The break will exit out of the for loop.

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  3. #3
    Registered User
    Join Date
    Jun 2002
    Posts
    11
    thank you

    know another problem i am having is, i have stored the data in the array.

    how do i go about adding all the individual numbers in the array.

    here is what i tried

    Code:
     for (row = 0; row < numofInts; row++)
                    {
                    sumofInts += numbers[row];
                    }

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    It looks okay to me, what isn't working properly?

    -Prelude
    My best code is written with the delete key.

  5. #5
    Registered User
    Join Date
    Jun 2002
    Posts
    11
    i got it now, thank you for your time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. beginner question about stopping a for-loop.
    By Techboy10 in forum C Programming
    Replies: 3
    Last Post: 12-11-2008, 05:15 PM
  2. Stopping Processes Question
    By brett in forum Linux Programming
    Replies: 3
    Last Post: 06-24-2007, 10:15 PM
  3. scanning in character string
    By zackboll in forum C Programming
    Replies: 12
    Last Post: 11-24-2004, 02:18 AM
  4. stopping in else block
    By linuxman in forum C Programming
    Replies: 3
    Last Post: 03-24-2004, 08:35 PM
  5. scanning in with gets() but not over inputing
    By stephanos in forum C Programming
    Replies: 1
    Last Post: 09-09-2002, 03:38 PM