1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
#include <iostream.h> // pour CIN & COUT
#include <iomanip.h> // pour le format de ces flux
#include <windows.h> // pour utiliser les API32
#include <stdio.h> // pour exploiter les Entrées/Sorties standards
#include <conio.h> // pour exploiter les Entrées/Sorties standards
//#include "RS_232.h"
//#include "send.h"
#include <fstream>
#include <string>
#include <cstring>
#include <sstream>
#include <math.h>
#include <stdlib.h>
using namespace std;
#define P 5
#define Vmax 1000 // maximum velocity
void Ffunction(int *i, string line, int *V);
//void Gfunction(int *i, string line,int *V,double *X0,double *Y0,double *Z0);
int i,j,space;
int main ()
{
double X0=0,Y0=0,Z0=0;
int V=0;
/*******************pour ouvrir un fichier */
string line;
ifstream myfile ("example.txt");
if (myfile.is_open())
{
while (! myfile.eof() ) //teste fin fichier
{
getline (myfile,line);
space=0;
for(i=0;space<1;i++)
{
switch (line[i])
{
case 'F': Ffunction(&i,line,&V);
break;
// case 'G': Gfunction(&i,line,&V,&X0,&Y0,&Z0);
break;
case '\0': space = 1; // end of line
}
}
}
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
//************************ F function(determination de la vitesse)
void Ffunction(int *i, string line, int *V) //(cursor position, read line, last velocity)
{
char velocity [100]={0};
//char direction;
int j, space=0;
*i=*i+1;
for (j=0;space<1;*i=*i+1,j++)
{
if (line[*i]=='\0' || isalpha(line[*i])>0)
space = 1;
else
velocity[j] = line[*i];
cout<<line[*i];
}
stringstream(velocity) >> *V;//convert velocity (string) to int (*V)
*i=*i-1;
} |
Partager