resolved!
From: _mario.lat (mario.lat_at_libero.it)
Date: 07/08/04
- Next message: Peter: "Default constructors, passing argument"
- Previous message: B. v Ingen Schenau: "Re: VS.NET Problem"
- Next in thread: Chris \( Val \): "Re: resolved!"
- Reply: Chris \( Val \): "Re: resolved!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 08 Jul 2004 18:50:57 GMT
Problem resolved. I write the code (for other people who will need it):
# include <iostream>
# include <fstream> // for file functions
# include <string> // string utilities
# include <climits>
# include <cstdlib>
# include <conio.h>
using namespace std;
void main()
{
char x; int card, val;
int count, tot=0;
//apro il file dove sono i dati per le distanze.
ifstream fdati("c:\\tabelladistanze.txt");
if(!fdati) {cout<<"errore\n"; exit(1);}
else cout<<"file "<<fdati<<" aperto\n";
string str;
int x1,x2;
float f;
while(fdati>>str>>x1>>x2>>f)
{
cout<<str<<" x1:"<<x1<<" x2"<<x2<<" f"<<f<<"\n";;
}
}
Thankyou to all!
Mario.
"_mario.lat" <mario.lat@libero.it> ha scritto nel messaggio
news:1ayEc.27292$GQ3.707359@twister2.libero.it...
> Sorry for my question,
> I'm new to C++.
> I'd like to read data from a file (data.txt) whi si made like that:
>
> xxx_string_xxxx 12 23.232 32
> yyy_string2_fjsd 23 344.123 233
> sdgfsagasfgsa 22 24.34 34.11
> .....
>
> each line have one string at begininng then three numers: how can I read
> this file and put
> this value in a vector?
> How can I do?
>
> Thank you in advance for the time you'lll spend for me.
> Mario.
>
>
>
- Next message: Peter: "Default constructors, passing argument"
- Previous message: B. v Ingen Schenau: "Re: VS.NET Problem"
- Next in thread: Chris \( Val \): "Re: resolved!"
- Reply: Chris \( Val \): "Re: resolved!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|