Thread: Process return 10 (0xA) : while loop finishes suddenly

  1. #1
    Registered User
    Join Date
    Aug 2015
    Posts
    5

    Question Process return 10 (0xA) : do while loop finishes suddenly

    Hi,

    I've got some issues with a code which is number generator using static local variable. The loop while finishes suddenly before get the next loop. I get "Process return 10 (0xA)" on Codeblocks;


    Code:
    #include <stdio.h>
    #include <stdlib.h>
    void series(void);
    
    char ch;
    
    
    void main(void)
    {
        do{
            series();
            printf("Do you want to call series() function again: y or n \n");
            scanf("%c",&ch);
        }while (ch=='y');
    
    void series(void)
    {
        static int series_num;
    
        series_num = series_num + 10;
        printf("series_num using static: %d \n", series_num);
    }
    Last edited by danielfdeus; 09-24-2015 at 07:18 PM.

  2. #2
    Registered User
    Join Date
    Sep 2015
    Location
    Australia
    Posts
    63
    Hi

    try leaving a space in the scanf " scanf(" %c",&ch); thus the scan does not see the "enter" from the first go..

    John

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,663
    > I get "Process return 10 (0xA)" on Codeblocks;
    That's because you wrote "void main", so the environment just gets whatever junk value happens to be around when it tries to retrieve the exit status of your program.

    FAQ > main() / void main() / int main() / int main(void) / int main(int argc, char *argv[]) - Cprogramming.com
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Aug 2015
    Posts
    5
    Thanks dude.

    I did it and it works perfectly.

  5. #5
    Registered User
    Join Date
    Aug 2015
    Posts
    5
    In that case, even change "void main()" to "int main" didn't solve the issue. I just put a space in 'scanf(" %c,&ch)'.
    Thanks by tips.

  6. #6
    Registered User Ktulu's Avatar
    Join Date
    Oct 2006
    Posts
    107
    In case you're not going to read the link regarding int main/void main that Salem suggested, then at least take a look at his avatar.
    This parameter is reserved

  7. #7
    Registered User
    Join Date
    Aug 2015
    Posts
    5
    Of course I read the his link. The information in that added to my knowledges.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program suddenly stops working.
    By KittenAqua in forum C Programming
    Replies: 5
    Last Post: 10-18-2011, 05:45 AM
  2. Why are these pointers suddenly changed?
    By Adam Rinkleff in forum C Programming
    Replies: 5
    Last Post: 07-28-2011, 11:45 PM
  3. Getting return value of another process
    By Sfpiano in forum Windows Programming
    Replies: 3
    Last Post: 08-25-2007, 10:44 AM
  4. system error when program finishes
    By h3ro in forum C++ Programming
    Replies: 7
    Last Post: 12-11-2006, 10:15 AM
  5. Seg Fault AFTER the program finishes..
    By CaptainMorgan in forum C++ Programming
    Replies: 1
    Last Post: 12-02-2006, 01:03 PM