answersLogoWhite

0

There are some cases when it makes your code simpler; for example a 'return' in the middle of a function can be replaced by a 'goto RETURN', where RETURN is a label near to the end of the function.

int myfunction (void)

{

FILE *f= NULL;

char *buff= NULL;

int rc= 0;

...

if (error_condition) return -1;

if (error_condition) { rc= -1; goto RETURN; }

...

RETURN:

if (f) fclose (f);

if (buff) free (buff);

if (debug) fprintf (stderr, "leaving function with rc=%d\n", rc);

return rc;

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Write a c for goto statement?

AGAIN: puts ("c"); goto AGAIN;


Is there any other keyword like goto in c plus plus?

The goto statement is a control flow statement that causes the CPU to jump to another spot in the code. This spot is identified through use of a statement label. The following is an example of a goto statement and statement label:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #include <iostream> #include <cmath> int main() { using namespace std; tryAgain: // this is a statement label cout << "Enter a non-negative number"; double dX; cin >> dX; if (dX < 0.0) goto tryAgain; // this is the goto statement cout << "The sqrt of " << dX << " is " << sqrt(dX) << endl; }


Why goto in C language is called a jumping statement?

Because it forces the program sequence to go to another place in the program, just as if jumping across somewhere. This goto is found in most programming languages.


Which statement is not frequently used in C plus plus?

The goto statement.


Why goto in c is a bad command?

A 'goto' statement immediately moves the execution of code to another part of the program. This makes the code difficult to follow and to debug. It is better practice to use If-then-else constructs to structure the program code.


Explain goto and return in c?

A return statement is used to transfer the program control flow to the function that has called the current function under execution. If the function is main, then the program returns the control flow to the operating system. The syntax for return statement is:return return-type;A goto statement is used to transfer the control flow to a particular labelled statement, not necessarily back to the calling program. There are somerestrictionson using a goto statement. For eg: the goto statement should not skip any variable declarations. The use of goto statement is usually considered as a bad programming practice. The syntax for goto statement is:goto label_name;....label_name: statements;


What is looping statement in turbo c?

while, for, do-while (and perhaps goto)


What programming languages use a C switch statement?

There are two programming languages which use a C switch statement. The two languages are C and C++, hence the name C switch statement. There may be more, but those are the most obvious ones


Example of procedural programming language and object oriented programming language?

example of procedural programming are those programming language that have structure e.g basic,fortran,c++,c and pascal e.t.c


In computer programming what is the difference between a switch and a transistor?

In the general subject of computer programming neither switch nor transistor exist as concepts. They are out of scope.The language C (and its relatives) have a switch statement, but still no concept of transistor.The switch statement of C is a statement in the general class of multiple way decision statements (aka multiple way branch statements) and are called other things in other languages:FORTRAN IV - computed GOTO statementFortran 95 - case constructBASIC - ON ... GOTO statementCOBOL - EVALUATE statementPL/1 - SELECT statementPascal - case statementAda - case statementetc.


What is if-statement in c programming language?

One of the statements, obviously.


Which statement should normally be avoided in c programme?

The word your teacher wants to hear is 'goto'.