-3

I wanted to know how to stop the program from executing the remaining code when a particular if condition returns true.

code sample

if(qname == QueName) {
    exit();
}

I tried using break. But Im getting an exception illegal use of break statement. Any help on this is much appreciated.

mvermand
  • 5,829
  • 7
  • 48
  • 74
vr3w3c9
  • 1,118
  • 8
  • 32
  • 57

1 Answers1

0

Return from a function when its work is done:

if(qname == QueName) {
    return;
}
Avantika Saini
  • 792
  • 4
  • 9
  • Function will not execute once it has returned. You said you are inside a function. This code will definitly work. Ese, share rest of your code and elaborate your problem statement – Avantika Saini Feb 28 '17 at 10:37
  • return; statement will stop the execution of further lines of code. Thanks! – S Kumar May 22 '20 at 15:00