"C2447: '{' : missing function header (old-style formal list?)"是什么意思?
What does "C2447: '{' : missing function header (old-style formal list?)" mean?
帮我解决这个错误!非常感谢!
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#include <math.h>
#include<iostream>
using namespace std;
#define N 2 // number of equations
#define dist 0.1 //step size
#define MIN 0.0 //minimum x
#define MAX 10.0 //maximum x
int main() {
double x, y[N];
//int j;
void runge4(double x, double y[], double step); //header
double f(double x, double y[], int i);
FILE *output; // save data in rk4.dat
output= fopen("rk4.dat","w");
y[0]= 1.0;//initial position
y[1]= 0.0;///initial velocity
fprintf(output, "%f/t%f/n",x,y[0]);
for (x= MIN; x<= MAX; x+= dist) {
runge4(x, y,dist);
fprintf(output,"%f/t%f/n", x, y[0]); //position vs time
}
printf("data stored in rk4.datn");
fclose(output);
} //end of main program
void runge4(double x, double y[], double step);
{ //rk4 subroutine
double f(double x, double y[], int i);
double h = step/2.0
t1[N],t2[N],t3[N],k1[N],k2[N],k3[N],k4[N];
int i;
for (i = 0; i<N; i++) t1[i]=y[i]+0.5*(k1[i]=step*f(x,y,i));
for (i = 0; i<N; i++) t2[i]=y[i]+0.5*(k2[i]=step*f(x+h,t1,i));
for (i = 0; i<N; i++) t3[i]=y[i]+(k3[i]=step*f(x+h,t2,i));
for (i = 0; i<N; i++) k4[i]=step*f(x+step,t3,i);
for (i = 0; i<N; i++) y[i]+=(k1[i]+2*k2[i]+2*k3[i]+k4[i])/6.0;
}
double f(double x, double y[], int i)
{ //RHS equations
if (i==0) return(y[1]); //RHS of first equation
if (i==1) return(-y[0]); //RHS of second equation
}
这是谐振子的四阶runger-kutta解,我从计算物理h . landau那里得到的,我不知道如何解决这个问题,请帮助我!
这一行(rk4 subroutine
注释前一行):
void runge4(double x, double y[], double step);
不应该在末尾有分号,因为您正在定义函数。
相关文章:
- 使用std::multimap迭代器创建std::list
- 来自 std::list 的迭代器 .end() 按预期返回"0xcdcdcdcdcdcdcdcd"但 .begin()
- 如何在 C 中正确使用 libiconv 使其不会报告"Arg list too long"?
- C++中带有List类的迭代器Segfault
- 使用"std::unordereded_map"映射到"std::list"对象
- GCC对可能有效的代码抛出init list生存期警告
- 这个语法std::class<>{}(arg1, arg2) 在C++中是什么意思?
- 使用std::list创建循环链表
- 重载Singly Linked List中的赋值运算符
- 标准 N3337 5.2.10 第 7 条中的C++"类型"是什么意思?
- "类模板示例<int>;"语句对 C++11 是什么意思?
- 线应该是什么意思
- 错误:无效的预处理指令 #i 的意思是 #if?
- "CID"在AT+HTTPPARA= "CID" ,1中是什么意思
- 这个语句到底是什么意思 stack<int, list<int> > 它与 stack 有何不同<int>?
- "friend std::ostream& operator<<(std::ostream& out, LinkedList& list)"是什么意思?
- 有人能解释一下他们的意思是list.pushback文档(不会使迭代器无效)吗
- "C2447: '{' : missing function header (old-style formal list?)"是什么意思?
- 模板参数的template-parameter-list是什么意思?
- "use of class template requires template argument list"是什么意思?