Program brief overview (3 body problem):
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
double ax, ay, t;
double dt;
/* other declarations including file output, N and 6 command line arguments */
...
int main(int argc, char *argv[])
{
int validinput;
...
/* input validation */
output = fopen("..", "w");
...
/* output validation */
for(i=0; i<=N; i++)
{
t = t + dt;
vx = ...
x = ...
vy = ...
y = ...
fprintf(output, "%lf %lf %lf\n", t, x, y);
}
fclose (output);
}
/* ext function to find ax, ay at different ranges of x and y */
{
declarations
if(x < 1)
{
ax = ...
}
else if(x==1)
{
ax = ...
}
...
else
{
...
}
if(y<0)
{
...
}
...
}
I get an error on the line '{ /* ext function to find ax, ay at different ranges of x and y */' saying "error: expected identifier or '(' before '{' token"
I think it may be due to not calling or creating the external function in the right way
Your function needs a name! A block of code outside any function is meaningless in C.
There are, in fact, several syntax/conceptual errors in your example. Please clean it up and clarify your question - I'll try to answer better when you've done so.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With