#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
Run Code Online (Sandbox Code Playgroud)
我需要这个代码的帮助.我的编译器一直要求我使用-fpermissive选项,但我不知道在哪里输入它.我已经粘贴了下面的代码和显示的错误.
using namespace std;
int cx = 0, cy = 0;
double x =0, y=0, r = 5;
int main(){
ofstream myfile;
myfile.open("dingo.txt");
for(int g =0 ; g <= 360; g++)
//find x and y
//Get points of a circle.
x = cx + r * cos(g);
y = cy + r * sin(g);
//This is what pops up below:
//In function int main()':
//Error: name lookup of 'g' changed for ISO 'for' scoping [-fpermissive]
//note: (if you use '-fpermissive' G++ will accept your code)
//where should I enter the required option?
myfile << "X: " << x << "; Y: " << y <<endl;
myfile.close();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
您可以"Other Options"在"Settings">中添加更多编译器标志"Compiler"

虽然我认为你应该先修复你的代码.例如,std::sin并std::cos接受弧度,而不是度数.你还需要围绕你的for陈述大括号.
for(int g =0 ; g <= 360; g++) {
//code here.
}
Run Code Online (Sandbox Code Playgroud)