Archive

Archive for the ‘C++’ Category

C++ Primer Plus and LearnCPP.com

July 26, 2012 1 comment

Two weeks back I’ve started to check C++, after a gap of almost 71/2 years. During these 71/2 years I’ve worked in a variety of technologies. Majority of them were related to web applications and scriptting languages.

Though I have used languages like Java, C#, VB.net, etc from time to time either for accomplishing some of my tasks or for doing some personal experiments or projects.

But when I returned back to C++ it was a bit different experience. I prefer learning or brushup things based on books and have read some great books along with some really bad ones. I feel that some authors really make things difficult for reader by going in a very complex way while describing things. I personally feel that writing is an art and some authors really mastered the art of writing and Stephen Prata is one the of the best author I’ve experienced.

Recently I bought C++ Primer Plus by Stephen Prata. I bought this purely based on the reviews about this in Amazon.com and my decision to buy this book was one of the best that I’ve made recently.

I haven’t read this book completely but I can assure you that this covers all the details about C++ in a very detailed manner. The writing style is simple and strightforward unlike some other books. I’d suggest this book to anyone who wants to learn C++ as a newbie or for someone with lots of programming experience as both can gain a lot of information from this. This book would be an asset to any C++ programmer.

Another great online reference for budding C++ programmers is LearnCPP.com. This resource maintains its quality throughout its tutorials. The writing style was simple and uncomplicated. I often found that conveying the concepts can be very difficult. But LearnCPP.com handled this very efficiently. I highly recommend this site to anyone who wants to learn C++ or bushup their C++ skills.

Categories: Books, C++

climits Symbolic Constants

July 26, 2012 Leave a comment

There can be situations from a code snippet needs to start from the first allowable value of variable of a particular type and goes until the final value that the type support. This kind of scenarios are frequent in embedded programming at least, which I am familiar with.

In C++ there are some symbolic constants available through which one can determine the minimum and max value of particular data type. These constants are a part of climits header files.

The following code snippet demonstrates this functionality

void showCLimitsSymbolicConstants(){
    std::cout<<"CHAR_BIT: "<<CHAR_BIT<<"\n";    //Number of bits in a char
    std::cout<<"CHAR_MIN: "<<CHAR_MIN<<"\tCHAR_MAX: "<<CHAR_MAX<<"\n";    //Min and maximum char value
    std::cout<<"SCHAR_MAX: "<<SCHAR_MAX<<"\tSCHAR_MIN: "<<SCHAR_MIN<<"\n"; //Max and Min signed char value
    std::cout<<"UCHAR_MAX: "<<UCHAR_MAX<<"\n"; //Max unsigned char value
    std::cout<<"SHRT_MAX: "<<SHRT_MAX<<"\tSHRT_MIN: "<<SHRT_MIN<<"\n";  //Max & min short value
    std::cout<<"USHRT_MAX: "<<USHRT_MAX<<"\n"; //max unsigned short value
    std::cout<<"INT_MAX: "<<INT_MAX<<"\tINT_MIN: "<<INT_MIN<<"\n"; //max and min signed int value
    std::cout<<"UINT_MAX: "<<UINT_MAX<<"\n"; //max unsigned int value
    std::cout<<"LONG_MAX: "<<LONG_MAX<<"\tLONG_MIN: "<<LONG_MIN<<"\n"; //max and min long  value
    std::cout<<"ULONG_MAX: "<<ULONG_MAX<<"\n";//max unsigned long value
    std::cout<<"LLONG_MAX: "<<LLONG_MAX<<"\tLLONG_MIN: "<<LLONG_MIN<<"\n";//max and min long long  value
    std::cout<<"ULLONG_MAX: "<<ULLONG_MAX<<"\n";//max unsigned long long value
    std::cin.get();
}
Categories: C++ Tags: ,