This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

A bug ( ? ) and a question


Dear Sirs,

I use the gcc 3.3.5 20050117 prerelease that came with SuSe 10 and have a
problem and a question.

The problem first:

When debugging programs like this:

quote
-----

using namespace std;

#include <iostream>
#include <cstring>


class Nwh {
    char Firstname [12];
    int age;
public:

    Nwh ( char * Firstname_, int age_ );
}; // class Nwh {

Nwh :: Nwh ( char * Firstname_, int age_ ) {
    strcpy ( Firstname, Firstname_ );
    age = age_;
} // Nwh :: Nwh ( char * Firstname_, int age_ ) {


int main ( ) {
    Nwh Me ( "Hans", 15 );
    cout << "Done";
    return 1;
} // int main ( ) {
    
unquote
-------


I can put a breakpoint in the subprogram, gdb says it has been put, but it
never stops there, and stepping through the program I see it pass my break. Of
course I collided to it in more complicated sources.

---

My problem is this:

Stroustrup: The C++ ... is very cumbersome to understand after chapter 20 or
so. I frequently have the problem to read ( sequence of charstrings, integers
and doubles ) as lines from a file built by some other program or by myself as
a form in textmode. `sscanf` has always been a stepchild for C and C++, and
the debugger handles it terribly. Integers and doubles read correctly by
`sscanf ( s+60, "%lf", Myint )` are OK when printed ( `cout << ...` ), but gdb
gives them as e.g. 3.43567655+345.

Stroustrup ch 20 and 21 give very little information on sprintf, and only
mentions sscanf once. On internet Google search on "C++ tutorial sstream"
gives > 800 hits, but only three really on sstreams and 1, maybe 2 can be
used.

But I have, as said, to read from a file ( `is.getline ( line, 200 )` ) a line
formatted as an 2 integers from position 10, resp 20, a string on positions 30
- 70, and a number of doubles at well-defined positions after that.

The string may include spaces, and that is the problem since a stringstream
thinks it has done what I asked for as soon as it finds a space, so I have to
tell him that he should read all 40 chars, no matter the contents are and then
start reading the trailing doubles. In the sources I can't find the
solution. setw(40) does not help me out. So I need some formatting directives
for sstream, such as `an integer from positions 1 to 10; possibly another
integer from positions 11 - 20; a string of chars, including spaces from
positions 30 - 70; ...' .

I have been looking in the gnu.org/onlinedocs manuals, but found nothing like
'<sstring>'.

Can you please  tell me how to solve my problem?

A second question is: How must I interpret the avalanche of @'s in
/usr/include/c++/3.3.5/ files?

If you find in my internetsite a reason for cooperation, I will be happy to
discuss that. In these days I make mainly diskutilities like signalling
double, triple, quadruple, ... files on 500 GB background memory, a standard
format for all kinds of textfiles etc.

Nieuwenhuizen, J.K.
2006-03-05T15:10

-- 
-----------------------------------------------------------------
Prof. Ir. J.K. Nieuwenhuizen       email:  jk@nieuwenhuizen-jk.nl
dom Paul Bellotweg 8            internet: www.nieuwenhuizen-jk.nl
5624 KZ Eindhoven
Netherlands                         Tel :    [{00xx|0}40] 2442226
-----------------------------------------------------------------




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]