C Program Stalls or Infinite Loops inside and else statement?

Posted by Bobby S on Stack Overflow See other posts from Stack Overflow or by Bobby S
Published on 2011-01-12T04:42:00Z Indexed on 2011/01/12 4:54 UTC
Read the original article Hit count: 197

I have this weird thing happening in my C program which has never happened to me before.

I am calling a void function with a single parameter, the function is very similar to this so you can get the jist:

...
printf("Before Call");
Dumb_Function(a);
printf("After Call");
...

...
void Dumb_Function(int a){
    if(a == null)
    {
    }
    else{
    int i;
    for(i=0; i<a; i++)
    {
        do stuff
    }
    printf("test");
    }
}

This will output

Before Call
test

and NOT "After Call" How is this possible? Why does my function not return? Did my program counter get lost? I can not modify it to a non void function.

When running the cursor will blink and I am able to type, I press CTRL+C to terminate.

Any ideas?

© Stack Overflow or respective owner

Related posts about c

    Related posts about if-else-statement