Bool type

Hi all,
may be that the answer to my question is simple but I can’t found documentation that can help me!!!
What I want to do is to execute a script that reads a boolean variable!!!
I tried in this way (obviously is just the code of interest and the filename is foo.C):

void foo()
{
bool mybool;
cin >> mybool;
cout << mybool << endl;
}

but it doesn’t work!!!
It sais:

Processing foo.C…
Error: Illegal pointer operation (tovalue) FILE:foo.C LINE:4
*** Interpreter error recovered ***

I tried several methods but the best I reached was to print the output exiting from Root (as if CINT flushes the output buffer while exits)!!!
My question is:
is it possible to use cin and cout for booleans (for other types there are no problems)?
Thanks!
Bye…

Hi,

I can not reproduce this problem with the latest version of root.
However the latest version of cint does not properly execute cint>>mybool;
So instead use an int or compile (with ACLiC for example) your macro.

Cheers,
Philippe.

Hi,

The problem with cint >> boolvar; not updating the variable will be fix in the next release.

Cheers,
Philippe.

And what about cout?
Is there the same problem?
It prints the output (for the bool) but only after “.q”!
Bye…

Have you used endofline (endl) ?

Antonio

Yes but this does not solve my problem!!!
Bye…

Hi,

I can reproduce any problem with cout and bool:

[quote]bash-2.05b$ root.exe


  •                                     *
    
  •    W E L C O M E  to  R O O T       *
    
  •                                     *
    
  • Version 4.01/05 15 December 2004 *
  •                                     *
    
  • You are welcome to visit our Web site *
  •      [root.cern.ch](http://root.cern.ch)            *
    
  •                                     *
    

Compiled for win32 with thread support.

CINT/ROOT C/C++ Interpreter version 5.15.159, Nov 14 2004
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] bool a = true
root [1] cout << a << endl;
1
root [2] .q
[/quote]

Philippe.

Thanks!!!