Message: G4cout weird behaviour Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question G4cout weird behaviour 

Forum: Documentation and Examples
Date: 30 Jan, 2009
From: Hans Wenzel <Hans Wenzel>

I am getting weird output. Using the std::cout with the code snipet below I get:

    G4String tagstring2, tagstring = "float ";
    std::cout << "here we go: " << std::endl;
    //    for (int i = 0; i < 28; i++) {
    for (int i = 0; i < 5; i++) {
        tagstring2 = tagstring + "hcal" + i + ":";
        tagstring = tagstring2;
        std::cout << "tagstring:  " << tagstring2 << std::endl;
    }

results as expected in the following output:

here we go:

tagstring:  float hcal0:
tagstring:  float hcal0:hcal1:
tagstring:  float hcal0:hcal1:hcal2:
tagstring:  float hcal0:hcal1:hcal2:hcal3:
tagstring:  float hcal0:hcal1:hcal2:hcal3:hcal4:

While using G4cout (code snipet below)

    G4String tagstr2, tagstr = "float ";
    G4cout << "here we go again: " << G4endl;
    //    for (int i = 0; i < 28; i++) {
    for (int i = 0; i < 5; i++) {
        tagstr2 = tagstr + "hcal" + i + ":";
        tagstr = tagstr;
        G4cout << "tagstr:  " << tagstr2 << G4endl;
    }

The output is very different (more or less garbage):

here we go again: tagstr: float hcal0tagstr: float hcal1tagstr: float hcal2tagstr: float hcal3tagstr: float hcal4tagstring: float hcal4:

Any idea what's going on.

thanks

Hans

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 More: Re: G4cout weird behaviour   (Krisztian Balla - 31 Jan, 2009)
(_ Idea: Re: G4cout weird behaviour   (Krisztian Balla - 31 Jan, 2009)
(_ Question: Re: G4cout weird behaviour   (Krisztian Balla - 31 Jan, 2009)
 Add Message Add Message
to: "G4cout weird behaviour"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]