JrdA wrote:
>
> Hi NG
>
> My programs does following:
>
> - ofstream writes fx. "1234#01/26/04#" to a txt-file
>
> Now i have a txt-file containing :
>
> 1234#01/26/04#
> 424#01/26/04#
> 324234#01/26/04#
>
> I then need ifstream to read the first ints until it reaches the # sign and
> then add them togheter.
>
> Can anyone help me with som code to do that?
I would do it the following way:
read an entire line into a std::string using getline
then search if and where there is a '#' character.
Split the string into 2 using the found position
Use the left half in a stringstream to use an op>> to read the int.
Now that you have that int, use it for whatever you like to do with it.
--
Karl Heinz Buchegger