Archived

This topic is now archived and is closed to further replies.

EvilJosh

Can someone help me with my C++

Recommended Posts

okay I re-started programing and I need some help with the int example. ( int long MyAge = 14 ) what is the LONG part and what does it mean...? I''m not just talking about LONG but all of them like int short... could one of you please help --- The EvilOne ---

Share this post


Link to post
Share on other sites
If you look in your local MSDN library you''d find a list of all of them


Base type Default sign Description
boolean unsigned 8-bit data item
byte - (not applicable) 8-bit data item
char unsigned 8-bit unsigned data item
double - 64-bit floating-point number
float - 32-bit floating-point number
handle_t - Primitive handle type
hyper signed 64-bit signed integer
int signed 32-bit signed integer
long signed 32-bit signed integer
short signed 16-bit signed integer
small signed 8-bit signed integer
void * - 32-bit context handle pointer type
wchar_t unsigned 16-bit unsigned data item


[type-specifier] [ signed | unsigned ] type-modifier [ type ] declarator-list;

type-specifier
Specifies a base_type, struct, union, enum type, or type identifier. An optional storage specification can precede type-specifier.

type-modifier
Specifies the keyword small, short, long, or hyper, which selects the size of the integer data. On 16-bit platforms, the size qualifier must be present.

declarator-list
Specifies one or more standard C declarators, such as identifiers, pointer declarators, and array declarators. (Function declarators and bit-field declarations are not allowed in structures that are transmitted in remote procedure calls. These declarators are allowed in structures that are not transmitted.) Separate multiple declarators with commas.
Examples

Share this post


Link to post
Share on other sites
boolean - used for data that can be true or false
ex: bool Done = false;

BYTE - (see unsigned char)

char - holds whole numbers between -128 and 127 (usually for ASCII character codes)
ex: MyHealth = 32;

unsigned char - holds whole numbers between 0 and 255
ex: char MyAge = 192;

double - holds VERY accurate numbers with decimals
ex: double MyInterest = 1.000040346736963;

float - holds accurate numbers with decimals
ex: float Pi = 3.14159; (note, it would be smarter to write it as 3.14159f so the compiler knows 3.14159 is a float to begin with)

int - holds whole numbers between -32768 and 32767
ex: MyScore = 2442;

long - holds whole numbers between -2147483648 and 2147483647
ex: YouScore = 5386994363;

short signed - (see int)
small signed - (see char)

Invader X
Invader''s Realm

Share this post


Link to post
Share on other sites
Umm, I don''t mean to be mean or rude but if the is confising you, you should probably go get a book like "Teach yourself C programming in 21 days" (first C book I read, in more than 21 days). variable declaration is one of the easiest things in a language. If you are getting stuck there then that is a sign that you need more of a background before you should start asking for help.



Jason Mickela
ICQ : 873518
E-Mail: jmickela@sbcglobal.net
------------------------------
"Evil attacks from all sides
but the greatest evil attacks
from within." Me
------------------------------

Share this post


Link to post
Share on other sites
quote:
Original post by griffenjam
Umm, I don''t mean to be mean or rude but if the is confising you, you should probably go get a book like "Teach yourself C programming in 21 days...


I agree, but skip C and go straight to C++. The two languages require very different ways of thinking, and many (well-versed) C programmers never really learn to leverage C++ (anywhere near) fully.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
yes but I don''t think you''ll ever become as good a C++ programmer as someone who started with C++ (assuming both of you are equally intelligent). That''s just the way programming works, your first language will always be your best and it will warp the way you see the world.

Share this post


Link to post
Share on other sites
That''s not true at all. I started out like Lowell did with QBasic, or actual line number BASIC rather, and then learned C. After I was using C for over a year, I started learning C++. Right now, I''m using C++''s object oriented style to my advantage with my current game engine. Things like stl, polymorphism, factories, and other C++ concepts that are specific to the language. You can learn these things, but you just have to find a use for them first.

dave

--
david@neonstar.net
neonstar entertainment

Share this post


Link to post
Share on other sites
quote:
Original post by Lowell Manners
I started with QBasic, then C, then C++. I believe that progressing the way I did gave me a foundation I wouldn''t have if I had just gone straight to c++.

That''s not necessarily true. The concepts of programming remain the same. The main difference between learning C++ first and learning C first (learning both properly!) is the mental approach to problem solving. Note that I said many - not all - well-versed C programmers (by which I mean programmers who have immersed themselves in the language) never use C++ to its full potential, largely because the similarity in syntax causes them to "think in C." C++ programmers, OTOH, are capable of using C to its max because C++ is a superset of C (they''ll be confined by the language).

If you''re learning now, learn C++. You can always pick up C later.

Share this post


Link to post
Share on other sites