Maybe this makes it more clear:
Code:
#include <sstream>
#include <fstream>
#include <stdio.h>
using namespace std;
int main()
{
//variables to be read
int speed;
int shield;
int thrust;
int turning;
char name[80];
FILE *fp; //fp is a file
fp=fopen("performance.txt", "r"); //Open text file called "performance" for reading only ("r")
fscanf(fp, "%s\n%d\n%d\n%d\n%d", name, &speed, &shield, &thrust, &turning); //scan text file for values and save them in the predefined variables name, speed, shield, thrust and turning
fclose(fp); //close text file
printf("name=%s\nspeed=%d\nshield=%d\nthrust=%d\nturning=%d\n", name, speed, shield, thrust, turning); //print retrieved data on screen
getchar(); //wait for user input to close the program
}
The performace text file looks like this:
Code:
Solaris_C062 //name
10 //speed
6 //shield
4 //thrust
9 //turning
Those comment parts aren't really there because the program can't ignore them.
Of course it can have way more variables, such as weight, CG position, MOI, etc... To use in simulator mode.