Thread: Problem with do while loop

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    20

    Problem with do while loop

    I am pretty sure my code is right i copied it right out of the book. But for some reason I get this error message

    First-chance exception at 0x667f6af2 (msvcr90d.dll) in doingWallE.exe: 0xC0000005: Access violation writing location 0x00000000.
    Unhandled exception at 0x667f6af2 (msvcr90d.dll) in doingWallE.exe: 0xC0000005: Access violation writing location 0x00000000.

    Code:
    #include "stdafx.h"
    #include "stdio.h"
    
    int main()
    {
    int value;
    	do
    	{
    	printf("\n\nenter a number: ");
    	scanf(" %d, &value");
    	}
    	while(value<=20);
    	return (0);
    }
    I know how while loops work, but I went back to my book to make sure I was doing it right because my project would give me the same error message. Then I copied this test code right at the book and all of the sudden I am getting the same error message. This happens only when I use do while loops. Can anyone tell me why is this happening?

    Also the program runs but it crashes as soon as I enter any input (a number below or above 20)
    Last edited by tru.cutru; 06-29-2008 at 10:03 PM.

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    It is
    Code:
    scanf("%d", &value);
    You have the " wrong.

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    20
    OH JESUS. I probably had that wrong on my other code too. Thanks

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