C++;错误:ISO C++;禁止指针和整数[-fppermissive]之间的比较 我是一个初学者C++程序员,对C++的知识很少。我一直在IDE和编译器上创建一个程序:Dev-C++5.6.3。我遇到了这个错误:ISO C++禁止指针和整数之间的比较[fPield]。我不知道这意味着什么,但我将把整个代码放在这里: #include <iostream> #include <stdio.h> #include <cstdlib> #include <conio.h> using namespace std; // This is the Cleaner and Updated version of the test program. int main(int argc, char** argv) { Introduction: //Introduction to The Program and Little Information About it. cout << "________________________________________________________________________________" << endl; cout << " Introduction " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Ryan's C++ Program" << endl; cout << "This Program is in Beta and is Glitchy" << endl; cout << "Press Any Key to Continue..." << endl; getch(); goto Lobby; Lobby: //Main Place, Here you can go to multiple sections in the program that repersent diffrent functions. system("CLS"); int choice; cout << "________________________________________________________________________________" << endl; cout << " Lobby " << endl; cout << "________________________________________________________________________________" << endl; cout << "Please Enter the Corisponding Number to The Section You Want to Go to." << endl; cout << "1. Information (About Program)" << endl; cout << "2. Calculator" << endl; cout << "3. Games" << endl; cout << "4. Programs (To Open)" << endl; cout << "5. Shutdown Options (To Computer)" << endl; cout << "6. Help" << endl; cout << "7. About Me" << endl; cout << "8. Test" << endl; cout << "9. Exit Program" << endl; cout << "10. Update News" << endl; cout << "Input Number:"; scanf ("%d", &choice); if (choice == 1) goto Information; if (choice == 2) goto Calculator; if (choice == 3) goto Games; if (choice == 4) goto Programs; if (choice == 5) goto Shutdown; Information: //Information About The Program system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Information " << endl; cout << "________________________________________________________________________________" << endl; cout << "This is Information about The Program:" << endl; cout << "This Program is a C++ Console Program Using a Source Code Made by Ryan Park." << endl; cout << "This Program Was Made using the IDE and Compiler DEV-C++ Version 5.6.3." << endl; cout << "This Program is in Beta 1.0.0 and Might be Glitchy." << endl; cout << "To See the Contents of Every New Update, Go To: Update News Section." << endl; cout << "Press Any Key to Go Back to Lobby...." << endl; getch(); system("CLS"); cout << "Going Back to Lobby..." << endl; cout << "Press Any Key to Continue...." << endl; getch(); goto Lobby; Error: //Programs Emergency Error System. system("CLS"); cout << "Error Detected, Shutting Down Program..." << endl; cout << "Press Any Key to Continue...."; getch(); return 0; Calculator: //Calculator With 4 Functions int num1; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Calculator " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Calculator!" << endl; cout << "To Begin, Please Select the Type of Operation You Want to Perform" << endl; cout << "1. Addition" << endl; cout << "2. Subtraction" << endl; cout << "3. Multiplication" << endl; cout << "4. Division" << endl; cout << "Input Number:"; scanf ("%d", &num1); if (num1 == 1) goto Addition; if (num1 == 2) goto Subtraction; if (num1 == 3) goto Multiplication; if (num1 == 4) goto Division; else goto Error; Addition: //Part of Calculator int num2; int num3; int sum; int input; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Addition " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Addition!" << endl; cout << "1st Number:"; scanf ("%d", &num2); cout << "2nd Number:"; scanf ("%d", &num3); sum = num2 + num3; printf ("\nThe Answer is: %d", sum); cout << "\nPress Any Key to Continue...."; getch(); system ("CLS"); cout << "1. Go Back to Lobby" << endl; cout << "2. Go Back to Calculator" << endl; cout << "3. Make Another Addition Equation" << endl; cout << "Input Number:"; scanf ("%d", &input); if (input == 1) goto Lobby; if (input == 2) goto Calculator; if (input == 3) goto Addition; else goto Error; Subtraction: //Part of Calculator int num4; int num5; int diffrence; int input1; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Subtraction " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Subtraction" << endl; cout << "1st Number:"; scanf ("%d", &num4); cout << "2nd Number:"; scanf ("%d", &num5); diffrence = num4 - num5; printf ("\nThe Answer is: %d", diffrence); cout << "\nPress Any Key to Continue...." ; getch(); system("CLS"); cout << "1. Go Back to Lobby" << endl; cout << "2. Go Back to Calculator" << endl; cout << "3. Make Another Subtraction Operation" << endl; cout << "Input Number:"; scanf ("%d", &input1); if (input1 == 1) goto Lobby; if (input1 == 2) goto Calculator; if (input1 == 3) goto Subtraction; else goto Error; Multiplication: //Part of Calculator int num6; int num7; int answer; int choice2; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Multiplication " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Multiplication" << endl; cout << "1st Number:"; scanf ("%d", &num6); cout << "2nd Number:"; scanf ("%d", &num7); answer = num6 * num7; printf ("\nThe Answer is: %d", answer); cout << "\nPress Any Key to Continue...."; getch(); system("CLS"); cout << "1. Go Back to Lobby" << endl; cout << "2. Go Back to Calculator" << endl; cout << "3. Make Another Multiplication Equation" << endl; cout << "Input Number:"; scanf ("%d", choice2); if (choice2 == 1) goto Lobby; if (choice2 == 2) goto Calculator; if (choice2 == 3) goto Multiplication; else goto Error; Division: //Part of Calculator int num8; int num9; int quotient; int choice3; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Division " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Division" << endl; cout << "1st Number:"; scanf ("%d", &num8); cout << "2nd Number:"; scanf ("%d", &num9); quotient = num8 / num9 ; printf("\nThe Answer is: %d", quotient); cout << "\nPress Any Key to Continue...."; getch(); system("CLS"); cout << "1. Go Back to Lobby" << endl; cout << "2. Go Back to Calculator" << endl; cout << "3. Make Another Division Equation" << endl; cout << "Input Number:"; scanf ("%d", choice3); if (choice3 == 1) goto Lobby; if (choice3 == 2) goto Calculator; if (choice3 == 3) goto Division; else goto Error; Games: //Games Section. You Can play Games Here, Or Open Some. (NOT FINISHED/NOT STARTED) system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Games " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Games" << endl; cout << "I Have not Started this Section Yet, But check here in the next update!" << endl; cout << "Current Version: BETA 1.0.0" << endl; cout << "Press Any Key to Continue...." << endl; getch(); cout << "Going Back to Lobby..." << endl; cout << "Press Any Key to Continue...." << endl; getch(); goto Lobby; Programs: //Programs, To Open Programs on Your Computer system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Programs " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Programs" << endl; cout << "I have not Started this Section Yet, But check here in the next update!" << endl; cout << "Current Version: BETA 1.0.0" << endl; cout << "Press Any Key to Continue...." << endl; getch(); cout << "Going Back to Lobby..." << endl; cout << "Press Any Key to Continue...." << endl; getch(); goto Lobby; Shutdown: //Shutdown, To Shutdown, Restart and Log Off Computer. int input3; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Shutdown " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to the Shutdown Section" << endl; cout << "Which Operation Would you Like to Operate?" << endl; cout << "1. Shutdown" << endl; cout << "2. Restart" << endl; cout << "3. Log Off" << endl; cout << "4. Go Back to Lobby"; cout << "Input Number:" << endl; scanf ("%d",&input3); if (input3 == 1) goto Shut; if (input3 == 2) goto Restart; if (input3 == 3) goto Log; if (input3 == 4) goto Lobby; else goto Error; Shut: char inputy; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Shutdown " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Shutdown" << endl; cout << "This Program Will Now Shutdown your Computer, Make Sure to Close and Save Your Files." << endl; cout << "Press Any Key to Continue...." << endl; getch(); cout << "THIS WILL SHUTDOWN YOUR COMPUTER, ARE YOU SURE YOU WANT TO DO THIS?" << endl; cout << "(Y/N):"; scanf ("%c", &inputy); if (inputy == "Y") goto Shut2; if (inputy == "y") goto Shut2; if (inputy == "n") goto Lobby; if (inputy == "N") goto Lobby; else goto Error; Shut2: cout << "Shutting Down Computer...." << endl; cout << "Press Any Key to Continue...." << endl; getch(); system("shutdown -s -t 10"); Restart: int inputn; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Restart " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Restart" << endl; cout << "This Program Will Now Restart Your Computer, Make Sure to Close and Save Your Files." << endl; cout << "Press Any Key to Continue...." << endl; getch(); cout << "THIS PROGRAM WILL NOW RESTART YOUR COMPUTER, ARE YOU SURE YOU WANT TO DO THIS?" << endl; cout << "(Y/N):"; scanf ("%c", &inputn); if (inputn == "Y") goto Re2; if (inputn == "y") goto Re2; if (inputn == "N") goto Lobby; if (inputn == "n") goto Lobby; else goto Error; Re2: cout << "Restarting Computer...." << endl; cout << "Press Any Key to Continue...." << endl; getch(); system("shutdown -r -t 10"); Log: int inputl; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Log Off " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Log Off" << endl; cout << "This Program Will Now Log Off Your Computer, Make Sure to Close And Save Your FIles." << endl; cout << "Press Any Key to Continue...." << endl; getch(); cout << "THIS PROGRAM WILL NOW LOG OFF YOUR COMPUTER, ARE YOU SURE YOU WANT TO DO THIS?" << endl; cout << "(Y/N):"; scanf ("%c", &inputl); if (inputl == "Y") goto Log2; if (inputl == "y") goto Log2; if (inputl == "N") goto Lobby; if (inputl == "n") goto Lobby; else goto Error; Log2: cout << "Logging Off Computer...." << endl; cout << "Press Any Key to Continue...." << endl; getch(); system("shutdown -l -t 10"); #包括 #包括 #包括 #包括 使用名称空间std; //这是测试程序的更干净和更新版本。 int main(int argc,字符**argv){ 简介:/项目简介,相关信息很少。 cout

C++;错误:ISO C++;禁止指针和整数[-fppermissive]之间的比较 我是一个初学者C++程序员,对C++的知识很少。我一直在IDE和编译器上创建一个程序:Dev-C++5.6.3。我遇到了这个错误:ISO C++禁止指针和整数之间的比较[fPield]。我不知道这意味着什么,但我将把整个代码放在这里: #include <iostream> #include <stdio.h> #include <cstdlib> #include <conio.h> using namespace std; // This is the Cleaner and Updated version of the test program. int main(int argc, char** argv) { Introduction: //Introduction to The Program and Little Information About it. cout << "________________________________________________________________________________" << endl; cout << " Introduction " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Ryan's C++ Program" << endl; cout << "This Program is in Beta and is Glitchy" << endl; cout << "Press Any Key to Continue..." << endl; getch(); goto Lobby; Lobby: //Main Place, Here you can go to multiple sections in the program that repersent diffrent functions. system("CLS"); int choice; cout << "________________________________________________________________________________" << endl; cout << " Lobby " << endl; cout << "________________________________________________________________________________" << endl; cout << "Please Enter the Corisponding Number to The Section You Want to Go to." << endl; cout << "1. Information (About Program)" << endl; cout << "2. Calculator" << endl; cout << "3. Games" << endl; cout << "4. Programs (To Open)" << endl; cout << "5. Shutdown Options (To Computer)" << endl; cout << "6. Help" << endl; cout << "7. About Me" << endl; cout << "8. Test" << endl; cout << "9. Exit Program" << endl; cout << "10. Update News" << endl; cout << "Input Number:"; scanf ("%d", &choice); if (choice == 1) goto Information; if (choice == 2) goto Calculator; if (choice == 3) goto Games; if (choice == 4) goto Programs; if (choice == 5) goto Shutdown; Information: //Information About The Program system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Information " << endl; cout << "________________________________________________________________________________" << endl; cout << "This is Information about The Program:" << endl; cout << "This Program is a C++ Console Program Using a Source Code Made by Ryan Park." << endl; cout << "This Program Was Made using the IDE and Compiler DEV-C++ Version 5.6.3." << endl; cout << "This Program is in Beta 1.0.0 and Might be Glitchy." << endl; cout << "To See the Contents of Every New Update, Go To: Update News Section." << endl; cout << "Press Any Key to Go Back to Lobby...." << endl; getch(); system("CLS"); cout << "Going Back to Lobby..." << endl; cout << "Press Any Key to Continue...." << endl; getch(); goto Lobby; Error: //Programs Emergency Error System. system("CLS"); cout << "Error Detected, Shutting Down Program..." << endl; cout << "Press Any Key to Continue...."; getch(); return 0; Calculator: //Calculator With 4 Functions int num1; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Calculator " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Calculator!" << endl; cout << "To Begin, Please Select the Type of Operation You Want to Perform" << endl; cout << "1. Addition" << endl; cout << "2. Subtraction" << endl; cout << "3. Multiplication" << endl; cout << "4. Division" << endl; cout << "Input Number:"; scanf ("%d", &num1); if (num1 == 1) goto Addition; if (num1 == 2) goto Subtraction; if (num1 == 3) goto Multiplication; if (num1 == 4) goto Division; else goto Error; Addition: //Part of Calculator int num2; int num3; int sum; int input; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Addition " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Addition!" << endl; cout << "1st Number:"; scanf ("%d", &num2); cout << "2nd Number:"; scanf ("%d", &num3); sum = num2 + num3; printf ("\nThe Answer is: %d", sum); cout << "\nPress Any Key to Continue...."; getch(); system ("CLS"); cout << "1. Go Back to Lobby" << endl; cout << "2. Go Back to Calculator" << endl; cout << "3. Make Another Addition Equation" << endl; cout << "Input Number:"; scanf ("%d", &input); if (input == 1) goto Lobby; if (input == 2) goto Calculator; if (input == 3) goto Addition; else goto Error; Subtraction: //Part of Calculator int num4; int num5; int diffrence; int input1; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Subtraction " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Subtraction" << endl; cout << "1st Number:"; scanf ("%d", &num4); cout << "2nd Number:"; scanf ("%d", &num5); diffrence = num4 - num5; printf ("\nThe Answer is: %d", diffrence); cout << "\nPress Any Key to Continue...." ; getch(); system("CLS"); cout << "1. Go Back to Lobby" << endl; cout << "2. Go Back to Calculator" << endl; cout << "3. Make Another Subtraction Operation" << endl; cout << "Input Number:"; scanf ("%d", &input1); if (input1 == 1) goto Lobby; if (input1 == 2) goto Calculator; if (input1 == 3) goto Subtraction; else goto Error; Multiplication: //Part of Calculator int num6; int num7; int answer; int choice2; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Multiplication " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Multiplication" << endl; cout << "1st Number:"; scanf ("%d", &num6); cout << "2nd Number:"; scanf ("%d", &num7); answer = num6 * num7; printf ("\nThe Answer is: %d", answer); cout << "\nPress Any Key to Continue...."; getch(); system("CLS"); cout << "1. Go Back to Lobby" << endl; cout << "2. Go Back to Calculator" << endl; cout << "3. Make Another Multiplication Equation" << endl; cout << "Input Number:"; scanf ("%d", choice2); if (choice2 == 1) goto Lobby; if (choice2 == 2) goto Calculator; if (choice2 == 3) goto Multiplication; else goto Error; Division: //Part of Calculator int num8; int num9; int quotient; int choice3; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Division " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Division" << endl; cout << "1st Number:"; scanf ("%d", &num8); cout << "2nd Number:"; scanf ("%d", &num9); quotient = num8 / num9 ; printf("\nThe Answer is: %d", quotient); cout << "\nPress Any Key to Continue...."; getch(); system("CLS"); cout << "1. Go Back to Lobby" << endl; cout << "2. Go Back to Calculator" << endl; cout << "3. Make Another Division Equation" << endl; cout << "Input Number:"; scanf ("%d", choice3); if (choice3 == 1) goto Lobby; if (choice3 == 2) goto Calculator; if (choice3 == 3) goto Division; else goto Error; Games: //Games Section. You Can play Games Here, Or Open Some. (NOT FINISHED/NOT STARTED) system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Games " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Games" << endl; cout << "I Have not Started this Section Yet, But check here in the next update!" << endl; cout << "Current Version: BETA 1.0.0" << endl; cout << "Press Any Key to Continue...." << endl; getch(); cout << "Going Back to Lobby..." << endl; cout << "Press Any Key to Continue...." << endl; getch(); goto Lobby; Programs: //Programs, To Open Programs on Your Computer system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Programs " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Programs" << endl; cout << "I have not Started this Section Yet, But check here in the next update!" << endl; cout << "Current Version: BETA 1.0.0" << endl; cout << "Press Any Key to Continue...." << endl; getch(); cout << "Going Back to Lobby..." << endl; cout << "Press Any Key to Continue...." << endl; getch(); goto Lobby; Shutdown: //Shutdown, To Shutdown, Restart and Log Off Computer. int input3; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Shutdown " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to the Shutdown Section" << endl; cout << "Which Operation Would you Like to Operate?" << endl; cout << "1. Shutdown" << endl; cout << "2. Restart" << endl; cout << "3. Log Off" << endl; cout << "4. Go Back to Lobby"; cout << "Input Number:" << endl; scanf ("%d",&input3); if (input3 == 1) goto Shut; if (input3 == 2) goto Restart; if (input3 == 3) goto Log; if (input3 == 4) goto Lobby; else goto Error; Shut: char inputy; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Shutdown " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Shutdown" << endl; cout << "This Program Will Now Shutdown your Computer, Make Sure to Close and Save Your Files." << endl; cout << "Press Any Key to Continue...." << endl; getch(); cout << "THIS WILL SHUTDOWN YOUR COMPUTER, ARE YOU SURE YOU WANT TO DO THIS?" << endl; cout << "(Y/N):"; scanf ("%c", &inputy); if (inputy == "Y") goto Shut2; if (inputy == "y") goto Shut2; if (inputy == "n") goto Lobby; if (inputy == "N") goto Lobby; else goto Error; Shut2: cout << "Shutting Down Computer...." << endl; cout << "Press Any Key to Continue...." << endl; getch(); system("shutdown -s -t 10"); Restart: int inputn; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Restart " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Restart" << endl; cout << "This Program Will Now Restart Your Computer, Make Sure to Close and Save Your Files." << endl; cout << "Press Any Key to Continue...." << endl; getch(); cout << "THIS PROGRAM WILL NOW RESTART YOUR COMPUTER, ARE YOU SURE YOU WANT TO DO THIS?" << endl; cout << "(Y/N):"; scanf ("%c", &inputn); if (inputn == "Y") goto Re2; if (inputn == "y") goto Re2; if (inputn == "N") goto Lobby; if (inputn == "n") goto Lobby; else goto Error; Re2: cout << "Restarting Computer...." << endl; cout << "Press Any Key to Continue...." << endl; getch(); system("shutdown -r -t 10"); Log: int inputl; system("CLS"); cout << "________________________________________________________________________________" << endl; cout << " Log Off " << endl; cout << "________________________________________________________________________________" << endl; cout << "Welcome to Log Off" << endl; cout << "This Program Will Now Log Off Your Computer, Make Sure to Close And Save Your FIles." << endl; cout << "Press Any Key to Continue...." << endl; getch(); cout << "THIS PROGRAM WILL NOW LOG OFF YOUR COMPUTER, ARE YOU SURE YOU WANT TO DO THIS?" << endl; cout << "(Y/N):"; scanf ("%c", &inputl); if (inputl == "Y") goto Log2; if (inputl == "y") goto Log2; if (inputl == "N") goto Lobby; if (inputl == "n") goto Lobby; else goto Error; Log2: cout << "Logging Off Computer...." << endl; cout << "Press Any Key to Continue...." << endl; getch(); system("shutdown -l -t 10"); #包括 #包括 #包括 #包括 使用名称空间std; //这是测试程序的更干净和更新版本。 int main(int argc,字符**argv){ 简介:/项目简介,相关信息很少。 cout,c++,shutdown,dev-c++,C++,Shutdown,Dev C++,“Y”,“Y”,“n”,和“n”是C样式的字符串,是以null结尾的字符数组。在尝试比较它们时,它们会退化为指向常量字符的指针。另一方面,输入声明为int。这是指针错误和整数错误之间比较的根源 要解决此问题,请将输入与字符而不是字符串进行比较:'Y'、'Y'、'n'和'n'(请注意单引号,而不是双引号).您还有一个问题。您声明了int-inputy;,但您正试图通过执行scanf(“%c”和&inputy)来读取字符;。格式字符串%c与&inputy的数据类型不匹配。如果要读取字符,应使用正确的

“Y”
“Y”
“n”
,和
“n”
是C样式的字符串,是以null结尾的字符数组。在尝试比较它们时,它们会退化为指向
常量字符的指针。另一方面,
输入
声明为
int
。这是指针错误和整数错误之间比较的根源


要解决此问题,请将
输入
与字符而不是字符串进行比较:
'Y'
'Y'
'n'
'n'
(请注意单引号,而不是双引号).

您还有一个问题。您声明了
int-inputy;
,但您正试图通过执行
scanf(“%c”和&inputy)来读取字符;
。格式字符串
%c
&inputy
的数据类型不匹配。如果要读取字符,应使用正确的输入变量类型:

char inputy;

scanf("%c", &inputy);

@drescherjm,
goto
在某些情况下可能是个好主意,但我敢打赌对于初学者来说绝对不是个好主意。我发现
goto
唯一的好用途是在某些神秘情况下的错误恢复。就像在一个平台上没有异常处理一样。也就是说,
lobble
Shut2
,以及
错误
没有发布,因此无法知道这里发生了什么。另一个大问题是
cout
)和
scanf
getch
)的混合代码。这可能会有各种奇怪的副作用,因为这两个I/O库不总是保持同步。这个程序看起来像是从GWBASIC直接翻译。C++比使用<代码> Goto < /C> >有更好的控制程序流的方式。还有一个小问题:<代码> %C<代码> > <代码> SCANF需要的是
char*
,而不是
int*
。还需要进行更改,要么
inputy
char
,要么
scanf(“%c”
)不能使用。是的,由于“字符”太多而造成的混乱C中的函数使用
int
传递或返回字符。想想看,如果在一个小小的endian平台上运行,并且如果
inputy
使用的内存通过某种方式初始化为
0
,那么即使指针指向错误的类型,也会观察到正确的行为(因为指针指向的字节是
int
的最低顺序字节)。就语言而言,绝对是“未定义的行为”。