vendredi 2 mars 2018

Using getline value in if statement

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

struct info
{
     char path[20];
     int time;  
};


int main()
{
     int n;
     info function[30];
     ifstream fd("L1.txt");
     ofstream fr("L2.txt");
     fd >> n;
for(int i = 1;i<=n;i++)
{
     fd >> ws;
     fd.get(function[i].path,20);
     fd >> function[i].time;
}

 fd.close();
 fr.close();
 return 0;
}

Basically i'm trying to find a way how to check function[i].path value in if statement, since it is 2 words 'City park' i cant equate it to string. Anybody have any ideas?

Aucun commentaire:

Enregistrer un commentaire