Error goto

0 Alexander Liakopoulos · April 28, 2015
Could you tell me why the compiler finds error at the goto ??
The code is writen in Visual Studio...
Thanks in advance!!!

(hit>1)? goto ST3;

printf("Give me your next move(s):");


Post a Reply


Oldest  Newest  Rating
+1 Alexander Liakopoulos · June 25, 2015
Thank you ALL for responses!!  I solve the problem by compile it with Code Blocks ( gcc -g main.c )
The problem was that i was freeing "move" and then i was trying to store an alpharithmetic without use  malloc first!!
It was super segmentation fault!!!
I don't know why visual studio showed me that the core was in the goto line.

I really thank you!!! and appreciate it!!!
p.s. I did not response earlier because the dead line was approaching, i was in a hurry!! After that i forgot it :)
0 c student · April 29, 2015
scanf_s, _scanf_s_l, wscanf_s, _wscanf_s_l

Return value
Returns the number of fields successfully converted and assigned; the return value does not include fields that were read but not assigned. A return value of 0 indicates that no fields were assigned. The return value is EOF for an error, or if the end-of-file character or the end-of-string character is encountered in the first attempt to read a character. If format is a NULL pointer, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, scanf_s and wscanf_s return EOF and set errno to EINVAL.
0 Tatrasiel R · April 30, 2015
You write as if you started out with Assembly.

C has a slightly different flow . if I understand correctly what you're wanting, the following should be ok.

if (hit>1)
0   · May 3, 2015
I'm concerned because Alexander has presented a valid usecase for 'goto', with an error that may as well be unrelated to that usecase, and people seem to be jumping up and down about that 'goto'.

The criticism you seem to be expressing regarding the use of 'goto' was probably projected onto you when you were in early learning stages. You didn't know any better, but you could have done some research and presented a valid argument against that advice.

In 1968, Edsger W. Dijkstra write an article abolishing the goto statement in programming languages. This is most likely the very origin of your criticism. Yes, it was over forty years ago, and even Djikstra is sick of people misquoting this article.

If you just give the dogmatic token statement 'goto is evil' or 'never use goto' without the context building up to it that Djikstra applied so much effort expressing, you are missing the entire point. The message you're projecting is as silly as 'C is evil' or 'never use C'. You might as well sell your computer so you can buy some magic beans...

In reality, Djikstra didn't intend his message to be taken to such a gospel absolute. He later wrote "Please don't fall into the trap of believing that I am terribly dogmatical about [the go to statement]. I have the uncomfortable feeling that others are making a religion out of it, as if the conceptual problems of programming could be solved by a single trick, by a simple form of coding discipline!"

... and that is precisely what has happened here...
0 c student · April 29, 2015
it's telling you to not use goto because it's a terrible way to control the flow of a program.
0 SHIBAJI PAUL · April 29, 2015
First of all, please refrain yourself from using goto, if you going further with your programming venture it will really be a nightmare for you otherwise.
Secondly, you won't be able to use goto with ternary. Use if - else instead (as in the example below)
Third, if you are using ternary you are not allowed to omit the else part (part after colon (:) operator
Finally: your while does not seems to be working.


int main(){
    int k = 10;

    if (k%2==0)
        goto A;
        goto B;

        printf("Hello Bucky!");
        printf("U did great job, take my best regards.");
    return 0;

0   · April 29, 2015
"(hit>1)? goto ST3;"

What is this? A broken attempt at using the ternary operator? Perhaps you meant "if (hit > 1) { goto ST3; }"... Stick to what you know, and gather what you know from books rather than making it up yourself, because C isn't made up by you.
0 Tatrasiel R · June 26, 2015
thanks for following up....
  • 1



One of the most popular languages of all time.

Bucky Roberts Administrator