0
What is correct syntax for goto : line number?
while programming sometimes one needs to tell the program to return and start from line number .. It seemes that it should be : goto -> line .. but practically it does not work as i have experienced . Please help
7 Answers
+ 2
#include <iostream>
using namespace std;
int main() {
int x=3;
x: //this tells the compiler to come here
cout<<++x;
if(x<10)
goto x; //this is command statement
return 0;
}
This is the use of goto statement.
+ 1
In any case, the use of the goto statement is not recommended. Use functions and cycles.
+ 1
The thing is, its an abstraction. Programs dont keep track of lines.. We use lines to fit code into our view field, it is all one continuous "line" to the program. So that is why it is as Rishabh Agrawal explains.
0
Thank you Rishabh but i need to know how to tell my program to go back to an specific line to start from that line again
0
irajjs, it's not possible
0
I do not remember exactly but l think i have seen that in some other source codes
0
I think if progams can align a text and if they can show line numbers then they should be able to recognize the lines themselves!!