'go' 未在此范围内声明 (C++)
'go' was not declare in this scope (C++)
我试过声明但仍然错误,我尝试了其他几种方法但仍然错误,你能帮我吗?对不起,我是编程新手
'go' not declare in this scope我需要做什么?
此代码
#include <iostream>
#include <stdio.h>
#include <conio.h>
void push (void);
void pop (void);
void gotoxy(int x, int y);
int x, top;
int s [5], N=5;
main()
{
char pilih;
char barloop;
system ("cls");
gotoxy ( 25,7 ); puts ("coba stack"); ;
gotoxy ( 25,10 ); puts ("1. push");
gotoxy ( 25,13 ); puts ("2. pop");
gotoxy ( 25,16 ); puts ("3. exit");
gotoxy ( 25,19 ); printf("Pilih :");
scanf (" %x " , &pilih);
switch(pilih)
{
case 1: printf ("\n masukkan data x=;"),
scanf (" "); push(); getch(); break;
case 2: pop (); getch(); break;
case 3: exit(0);
}
go to char barloop;
}
void pop (void)
{
if (top > 0)
{
}
else { printf("\n\r stack kosong"); }
}
谢谢
关键字是 goto
,没有 space。
首先,C++中没有go to
关键字。它是 goto
,没有 space。
其次,您的 goto
句子语法不正确。 goto
语法如下所示:
dothisagian: // this is a statement label
// code
goto dothisagian;
它不会神奇地跳到你写的那一行。它跳转到语句标签。
- 第三,你必须写出 return 值
main()
是什么。
因此,您的代码应如下所示:
int main() // main returns an int
{
doThisAgain:
char barloop;
// code
goto doThisAgain;
}
- 最后一点:除非必要,否则你不应该在 C++ 中真正使用
goto
。您应该改用三种循环类型中的一种。
我试过声明但仍然错误,我尝试了其他几种方法但仍然错误,你能帮我吗?对不起,我是编程新手 'go' not declare in this scope我需要做什么?
此代码
#include <iostream>
#include <stdio.h>
#include <conio.h>
void push (void);
void pop (void);
void gotoxy(int x, int y);
int x, top;
int s [5], N=5;
main()
{
char pilih;
char barloop;
system ("cls");
gotoxy ( 25,7 ); puts ("coba stack"); ;
gotoxy ( 25,10 ); puts ("1. push");
gotoxy ( 25,13 ); puts ("2. pop");
gotoxy ( 25,16 ); puts ("3. exit");
gotoxy ( 25,19 ); printf("Pilih :");
scanf (" %x " , &pilih);
switch(pilih)
{
case 1: printf ("\n masukkan data x=;"),
scanf (" "); push(); getch(); break;
case 2: pop (); getch(); break;
case 3: exit(0);
}
go to char barloop;
}
void pop (void)
{
if (top > 0)
{
}
else { printf("\n\r stack kosong"); }
}
谢谢
关键字是 goto
,没有 space。
首先,C++中没有
go to
关键字。它是goto
,没有 space。其次,您的
goto
句子语法不正确。goto
语法如下所示:
dothisagian: // this is a statement label
// code
goto dothisagian;
它不会神奇地跳到你写的那一行。它跳转到语句标签。
- 第三,你必须写出 return 值
main()
是什么。
因此,您的代码应如下所示:
int main() // main returns an int
{
doThisAgain:
char barloop;
// code
goto doThisAgain;
}
- 最后一点:除非必要,否则你不应该在 C++ 中真正使用
goto
。您应该改用三种循环类型中的一种。