C++ Help Needed!

I know there are millions of types of variable types. But I've got no idea when to use which one. Such as, why use char, not string? Why use int, not short, or double and float? What's the difference? That's the main thing I need help in. Second - Definitions. What the HELL is a data type? I see it EVERYWHERE in my book. And what about literals. What are THOSE?? But there are no valid definitions! Help on that. And how do use the bool thing? What I know so far is bool myBool = true, but WHEN do we come across that variable... EVER? Last, but not least. Is it true that typedef only works on variables? I tried it on cout, but it didn't work. So help me on all of those. THanks!
char are used when we need do work with single letters like a,b,c.....
string are array/collection of characters.
if we need to work only with single char,then we use char not string because they occupy more space on the disk as compared to char.
Data types really are C++ 101.

Why do we use them? In short, memory allocation. But there's actually a lot more to it than that.

Here's an outline of what each of the core data types are. When to use them is up to you to determine.

http://www.cplusplus.com/doc/tutorial/variables/
int,short,long,float have different ranges.for example int in a 16 bit compiler have range from -32768 to 32767.if you input a value more or less than the given value, the output will be undesired and unpredictable for int.int occupy 2 byte of space.for long range is -2147483648 to 2147483647 and it occupies 4 byte.REMEMBER more the space occupied less will be the speed of running program.range of float -3.4e38 to 3.4e38 and space occupied is 4 byte. it can, unlike long and int, also store decimal values.
instead of using typedef on cout , u can use #define:-
for example

1
2
3
4
5
6
#include<iostream.h>
#define rap cout<<"Gangsta";
void main()
{
rap
}
Topic archived. No new replies allowed.