Thread: do while loop problem

  1. #1
    Registered User
    Join Date
    Nov 2003

    do while loop problem

    Hi everybody,

    I am back for help and advise, this time I do have problem with my loop.The loop is exited when the user type "0"(zero) or the same batter number(double entry), but didn't work!I have to find way to exit the loop and call the next fuction to generate adn print my table, after the array is fill up. Here is my code:

    struct batters get_entry (struct batters data[])
        int i;
    	int id_batter; 
    	printf("Enter batter number:");
    		printf("Enter number of hits:");
            scanf("%i", &data[i].hits); 
            printf("Enter number of walks:"); 
            scanf("%i", &data[i].walks);
            printf("Enter number of outs:"); 
            scanf("%i", &data[i].outs);
            printf("Enter 0 to exit program\n");
    	while (id_batter != 0 || id_batter != id_batter);
    	return (data[i]);
    Thanks !

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    (id_batter != 0 || id_batter != id_batter)
    (id_batter != 0 && id_batter != id_batter)
    To exit the loop with the first condition both conditions have to be false. To exit with the condition I gave only one has to be false.
    Last edited by Thantos; 11-30-2003 at 09:31 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Addition problem in loop
    By murjax in forum C Programming
    Replies: 3
    Last Post: 07-01-2009, 06:29 PM
  2. validation problem in a loop (newbie question)
    By Aisthesis in forum C++ Programming
    Replies: 11
    Last Post: 05-10-2009, 10:47 PM
  3. For Loop Problem
    By xp5 in forum C Programming
    Replies: 10
    Last Post: 09-05-2007, 04:37 PM
  4. Loop problem
    By Tesnik in forum C++ Programming
    Replies: 29
    Last Post: 08-23-2007, 10:24 AM
  5. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM