User forums > Using Code::Blocks

Immediate Window?

(1/2) > >>

jleach:
Hi all, TIA for any insight.  I tried searching but wasn't able to find what it was (I don't quite know what it's called).

In my VB IDE I have an Immediate Window... I can type an expression and get an answer...

-------
?1+2
3
-------

It's very limited to what can actually be done, but quite helpful in a lot of cases.

I'm very new to C++ but have found CB to be my favorite of the various IDE's that I've tried...  is there a similar functionality?  For instance, if I wanted to know what the ASCII value of "b" is, I might check it like so:

-------
?int("B")
-------


Many thanks if someone could advise.  As an alternative, I'm considering keeping a file open just to run quick checks like this in main() and output to the console, but it would be great if there's builtin functionality.

Cheers!
Jack









oBFusCATed:
C++ is compiled language most of the time (there is a c++ script interpreter (probably more than one)  - ask your search engine where to find it).
In its compiled form, C++ doesn't support what you want and what you've used to in the VB land.

jleach:
Thanks oBFusCATed, I took a quick look at script interpreters but it doesn't seem to be what I was hoping for either.  I'll take your word that I won't find this particular functionality in C programming.

cheers,

jleach:
This is a little out of the scope of the CB forum, but I figured seeing that the thread has already been started I might as well mention it in case some other newbie happened along looking for the same type of thing.

I read a few articles on attempts to "eval" an expression embedded within a string, and as stated, c++ will not support it due to the nature of the compilation.

However, if one wanted to, they could likely get similar functionality by doing the following:

1) create a template source file with an int main which has a cout << <expression>
2) create a program that opens the file, replaces <expression> with the passed string
3) automate the compiling of the file and execute it, ideally showing the expression return in the console.

The drawbacks that first come to mind doing this is including a plethera of standard libraries (a wait for compiling before you get your answer) and the limit that you could only use instristic types/objects (nothing custom), though this doesn't vary much from what the VB immediate offers.

Anyway, for one teaching themselves c++, this make make a nice little project for becoming familiar with file i/o and commandline compiling.  Thanks for the input.

oBFusCATed:
If one wants to execute scripts from your C/C++ application, one embeds a scripting language (Lua for example).
There is no point in implementing such fragile systems...

Navigation

[0] Message Index

[#] Next page

Go to full version