3
I have a question regarding if
.
I’m developing a program for the end of college semester and every time I need to use one if
and at the end of if
, I need you to go back to the beginning of the program. I’m having a hard time doing this.
Example:
Note: The code below is illustrative, because mine is too big and I will not be able to post here.
char op;
print("Digite algo");
scanf("%s", &op);
if (op == "nome") {
//algo aqui
}
if (op == "telefone") {
//algo aqui
}
if (op != 'nome' && op != 'telefone') {
//queria colocar algo aqui que fizesse o usuario voltar ao começo do codigo e pedir o valor da op pra ele de novo.
}
That my doubt is also related to switch case
, where in the default
I wanted to put something in that style (From back to the beginning of the code).
Can someone help me understand?
Put the rest of the code to see where it has to go.
– Maniero
Your code has problems is storing a string on a char and checking strings with
==
will not work. In my opinion, could usegoto
wouldn’t hurt much legibility, or As @bigown has already said post the rest of the code.– krystalgamer
Oh I got it. So my real code is very big, so I didn’t post it... That was a quick example of what I doubt. I should have specified that up there. : / I’ll edit. But thanks anyway. ;)
– Marcielli Oliveira