|
char is quite bad named because its name confuses too much the newbies.
of course, char goes to be used in strings, but first, that's not always true, and secondly, it does not serves only for that.
char in C/C++ is simply a signed byte, not more, not less. that means it can be used as a character (in strings), but also as an integer of 8 bits, or as a simple 8 bits array.
about the signature, yes, a char is by default signed, which means it contains values between [-128 ; +127].
but usually, the mainly used characters in the ascii tables are under the code 127 (over that, they are called extended char sets).
if you want more than that, you'll have to use UNICODE instead of ASCII, which stores a character on 16 bits instead...
to display a char string, simply use the "" notation, ,and the compiler will format your variable as needed ('\0' terminated)...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
toxcct wrote: char in C/C++ is simply a signed byte, not more, not less
It is simply a byte, but it can be signed or unsigned - it is left to compiler implementations to decide. For instance with VC++, char is signed by default unless the option /J is specified.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
-- modified at 16:10 Saturday 24th December, 2005
|
|
|
|
|
I'd suggesting creating a typdef as follows:
typedef unsigned char to BYTE;
BYTE's are pretty useful in walking through raw data streams, manipulating graphics by having to twiddle the bits of various pixels, etc.
Read more of what I have to say at http://directx9.blogspot.com/
|
|
|
|
|
hi....
I would like to Destroy MainFrame object Created by IMPLEMENT_DYNACREATE macro.coz, it gives memory leak when i close my apllecatin window.
plz...help he...how i colud do for this...
birajendu
CyberG India
Delhi
India
|
|
|
|
|
It deletes itself automatically after the window is destroyed. Check if you stopped your message pump prematurely.
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
I am creating a class for Bitmap.
I want to have detials regarding the RGBQUAD
which specifies the colors used in the bmp file
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
why reinventing the wheel ??
BITMAP structures already exist.
moreover, what is supposed to be the "quad" part of the name ?
RGB stands for red-green-blue ; quad is for...?
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
|
Hi,
Usually we creates the bitmap info directly from BITMAPINFO structure. But you can derive another structure from it. Then you will have access to RGBQUAD values. For knowing how to derive a structure from BITMAPINFO see the below code.
struct DIBINFO : public BITMAPINFO
{
RGBQUAD arColors[255]; // Adds an extra 255 entries to palette
operator LPBITMAPINFO() { return (LPBITMAPINFO) this; }
operator LPBITMAPINFOHEADER() { return &bmiHeader; }
RGBQUAD* ColorTable() { return bmiColors; }
};
Now instead of creating a Bitmap Info object of BITMAPINFO structure create it using DIBINFO structure. It is just simple as,
DIBINFO m_bitmapInfo;
Now you can change the RGBQUAD palette by changing the values in the arColors of the bitmap. For example here i am changing the palette to a gray scale one by filling same values at Blue, Green and Red.
for(int i = 0; i < 255; i++)
{
m_bitmapInfo.arColors[i].rgbBlue = i;
m_bitmapInfo.arColors[i].rgbGreen = i;
m_bitmapInfo.arColors[i].rgbRed = i;
m_bitmapInfo.arColors[i].rgbReserved = i;
}
There is another reserved member. It may be used in some other cases as Alpha. Normaly when you tell the color of a pixel you will specify 4 values.
They are,
1. Value of Red.
2. Value of Green.
3. Value of Blue.
4. Value of Alpha.
The alpha can be considered as the transparency.
Now while creating a bitmap pass the bitmap info as m_bitmapInfo. It will do the trick.
Thanks and Regards,
Amal P.
|
|
|
|
|
"As another example if running program on MSDOS machine we want to include file msdos.h otherwise a default.h file. A macro SYSTEM is set (by OS) to type of system so check for this: "
#if SYSTEM == MSDOS
#include <msdos.h>
#else
#include ``default.h''
#endif
--------------------
but how the value of "MSDOS" is obtained??
regards,
Rookie
Installing MFC...2% complete
|
|
|
|
|
Rokiee wrote: but how the value of "MSDOS" is obtained??
Try this
printf("MSDOS = %d", MSDOS);
Hope this is what you meant...
Happy christmas friends. May the Love of My Lord and Saviour Jesus bring forth Joy and Happiness into your life too.
<marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" hspace="2" vspace="2">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
sorry, i asked it wrong. i want to know like,
eg:
if(x==3)
{
//
}
else
{
}
here if only we know the value of 'x' we can check it right?? so i mean how do u get the value for "SYSTEM".? is it set somewhere out of the program??
regards,
Rookie
Installing MFC...2% complete
|
|
|
|
|
Rokiee wrote: but how the value of "MSDOS" is obtained??
you mean, how to set SYSTEM macro with MSDOS value ?
like this :
#define SYSTEM MSDOS
otherwise, if you want to actually test for the real Operating System to know if the program is running under DOS or not, you won't be able to do this at preprocessing time.
it is only at run time you will get the OS version and to one or one action...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
please refer my replies. above and below
regards,
Rookie
Installing MFC...2% complete
|
|
|
|
|
nope, you're wrong.
please refer the original question
sorry, i thought i talked to somebody else
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
-- modified at 6:05 Friday 23rd December, 2005
|
|
|
|
|
"But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1"> --[V]--
|
|
|
|
|
|
at compile time , _MSDOS_ would be true("defined") ,if its run in DOS right??
regards,
Rookie
Installing MFC...2% complete
|
|
|
|
|
Rokiee wrote: _MSDOS_ would be true("defined") ,if its run in DOS right??
definitely not !
refer my other answers
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
so is it a way to talk to the compiler? the
like , #ifdef _MSDOS_ (if the system runs on DOS)
include....
??
regards,
Rookie
Installing MFC...2% complete
|
|
|
|
|
i think either you don't undertand or you don't know what is the preprocessor.
the preprocessor creates a version of the file that is passed then to the compiler. but the compiler don't see exactly the file as you wrote it !!
lets take an example. if you have this :
#if defined(MY_MACRO)
#include "file1.h"
#else
#include "file2.h"
#endif
now, if you have MY_MACRO defined, the compiler will see :
#include "file1.h"
if not, it will see :
#include "file2.h"
but never the compiler sees the preprocessor directives.
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
2 things to try to demonstrate (on more time ) that you're wrong :
on the link you provide, it tells that the macro is not defined by VisualC++ compiler :
__MSDOS__ Turbo C, Borland C, and DJGPP
the second thing is that, even if the compiler sets this macro, the program won't be able to determine while running, if it is launched from windows, or from a plain MS-DOS console. such a test must be done a runtime, not compile time, and even less a preprocessing time.
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
The original poster asked to include a file depending on the environment. But now it seems that he wants to know the OS at runtime. So you are right.
this is this.
|
|
|
|
|
then whats the use of
#ifdef __GNUC__
##ifdef WIN32
regards,
Rookie
Installing MFC...2% complete
|
|
|
|
|
i don't know for __GNUC__
but i think the WIN32 macro tells the compiler that the target of the program will be Windows 95 (or later).
now if you #define __MSDOS__ (or such a macro), even if the program is build to be run on DOS (command line), it doesn't forbid anyone to run it under Windows XP for example. isn't it what you want ?
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|