Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: A Set of Qu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 9534 of 9831
Post > Topic >>

Re: A Set of Questions About Console I/O and Structures...

by Carl Barron <cbarron413@[EMAIL PROTECTED] > Apr 24, 2008 at 01:08 AM

In article
<4ccb4779-b255-42f9-a3f2-384a2ea3cbac@[EMAIL PROTECTED]
>,
philmasterplus <philmasterplus@[EMAIL PROTECTED]
> wrote:

> Here goes my list of questions that have been bugging me for a couple
> of days.
> 
> 
> 1. It seems that console I/O with "cout <<" and "cin >>" results in a
> bloated executable, whereas I/O functions from C such as printf() and
> scanf() make smaller, faster programs. Are there any other C/C++
> console I/O functions available, and which of them are fastest? Also,
> do you think I should stick to cin and cout when regarding speed,
> ****tability and the C++ philosophy?
> 
   The C++ library footprint is ussually bigger than the C library
footprint, since the C++ library is in general more general.  That
genealily is quite useful as soon as you get beyond built-in types and
'\0' terminated char arrays.  I'd stick to std::cin/cout unless there is
a real reason to 'drop down' to the <cstdio> routines [essentially the C
IO library].

> 2. I am using conio2.h from http://conio.sourceforge.net/
in my Visual
> C++ 2008 projects to create a 16-color text user interface. Is there a
> ****table (for Windows, Linux, and Mac) alternative to conio2? I'd like
> to have all functionality that conio2 provides. (The conio2 site
> provides do***entation.)
> 
     16 color text is a platform dependent feature and not ****table.  So
the answer is compiler/platform specific, and the results vary.

> 3. (If there is no suitable alternative to conio2) Microsoft Visual C+
> + Express 2008 seems to have a problem with structures. It gives a
> syntax error with the following code:
> 
>  someFunction(var1, var2, (COORD) {myInt1, myInt2});
> 
>   And this one:
> 
>  COORD cTemp = {0, 0};
> 
>   To fix these issues (which came from the conio2 library mentioned
> above), I have substituted the above to the below:
> 
>  COORD cTemp; //Tem****ary measure for VCX 2008
>  cTemp.X = myInt1;
>  cTemp.Y = myInt2;
>  someFunction(var1, var2, cTemp);
> 
>   Is there a way to eliminate the error without using tem****ary
> variables?

I am not familiar with MS 's conio stuff but I assume

struct COORD
{
    int X;
    int Y;
};

is the defintion cast in stone.

consider

struct my_coord:COORD
{
    my_coord(int a,int b):X(a),Y(b){}
};

this is nothing but adding a ctor to COORD so slicing should not be
a problem. [Passing a my_coord as a COORD only p***** the COORD
stuff not any thing added by my_coord.]

some_function(var1,var2,my_coord(myInt1,myInt2)); should work;

now all temps are  compiler generated and are destructed upon the
completion of some_function().

if this does not compile without warnings then you could use

some_function(var1,var2,static_cast<COORD>(my_coord(myInt1,myInt2)));

although the static_cast is most likely not needed.

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 3 Posts in Topic:
A Set of Questions About Console I/O and Structures...
philmasterplus <philma  2008-04-23 13:16:29 
Re: A Set of Questions About Console I/O and Structures...
Christopher <cpisz@[EM  2008-04-24 01:07:29 
Re: A Set of Questions About Console I/O and Structures...
Carl Barron <cbarron41  2008-04-24 01:08:40 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 21:52:22 CDT 2008.