> h.r...@gm... wrote:
>
> > Hi list,
> >
> > sorry, i know its bad style to ask nearly the same question twice, but i
> > make no progress with this problem. All in this file works well, except
> the
> > getline command. Allways the program crashed at this point. No
> exception, no
> > message, nothing. Has anyone a idea ?
> > Thanks in advance !!
> >
> > greetings
> > Horst
> >
> > // File: readdata.cpp
> > // Last: 6.8.02
> >
> > #include "readdata.h"
> >
> > #ifndef PROCABI_H
> > #include "procabi.h"
> > #endif
> >
> > #ifndef DATEI_H
> > #include "datei.h"
> > #endif
> >
> > #ifndef INOUT_H
> > #include "inout.h"
> > #endif
> >
> > #include <cstdio>
> > #include <cstdlib>
> > #include <cmath>
> > #include <string>
> > #include <iostream>
> > #include <fstream>
> >
> > using std::cout;
> > using std::cerr;
> > using std::getline;
> >
> > extern TProzessfaehigkeit pf;
> > extern TRead read;
> >
> > //-------------------------------------------------------------------
> >
> > bool isLine2Skip(const string& s) {
> > return ( (s[0] == ';') || // Comment
> > (s[0] == ' ') || // Space
> > s.empty() ); // Empty String
> > } // bool isLine2Skip()
> >
> > int RdFile(const string& s) {
> > try {
> > ifstream in(s.c_str());
> > if (!in) throw ERR_FILE_OPEN;
> >
> > string line;
> >
> > do {
> > getline(in, line);
> > } while (isLine2Skip(line));
> > pf.MeanS = atof(line.c_str());
> >
> > do {
> > getline(in, line);
> > } while (isLine2Skip(line));
> > pf.UTG = atof(line.c_str());
> >
> > do {
> > getline(in, line);
> > } while (isLine2Skip(line));
> > pf.OTG = atof(line.c_str());
> >
> > while (getline(in, line)) {
> > if (!isLine2Skip(line)) pf.Add(atof(line.c_str()));
> > } // while
> > return 0;
> > } // try
> >
> > catch(...) {
> > cerr << " Fehler in Datei " << s << endl;
> > return 1;
> > } // catch
> > } // int RdFile()
> >
> Hi Horst!
> The order of the parameters in the function
> getline is a "string" and an "int" (e.g. getline(string, 50)).
> I'm not sure, but think you've used getline(int,string),
> since your getline is this way: getline(in, line), and "line"
> is a string, isn't?
>
> Regards,
> Rafael Charnovscki
>
yes, it is. line is a string. In an ifstream.
Some Book examples uses my kind of getline e.g.
B. Eckel "Thinking in C++" Vol. 1 or in Accelerated C++ p.131
regards
Horst
--
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net
|