[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CCPlusPlusFAQAnswers

(C/C++ FAQ) Why should I program in C/C++? =

I get this a lot, and there are a lot of reasons why C/C++ is good to learn.

  1. First of all, it's type-strict. You can't get away with bad coding in this language, which is good practice.
  2. You must declare your variables, which makes you prepare for other languages, and makes your programming environment safer.
Here are some other reasons:

  1. Power. Some astronauts on a spaceship are counting on this programming language for their mission.
  2. Speed. If you need a language thats lickidy-split fast, this is your language.
  3. Inline ASM. If you have an inline assembler such as TASM, you can combine C/C++ and ASM, to make your programs even faster, and powerful.
C/C++ Programmers have also increased in demand, so considering your not that old (even so), we need you for the future! I don't have everything down, but those are more than enough ways to get you motivated!

(C/C FAQ) How do I go about learning?

If you plan on going on to C++ in some point in time, I would strongly suggest learning C++ first! The reason I say this is, many people say that people who learn C++ have an advantage, and since I've learned C first before C++, I know they aren't kidding . If you want to read a tutorial, you will find some good ones at the C/C++ Section.

If you want a book, here are my C++ suggestions: My C suggestions:

(C/C++ FAQ) What are libraries?

Surely they aren't the kind I know you visit to check out programming books, but they are similar. Libraries extend the C/C++ languages, and give more power to the user. For example Allegro, the graphics programming library gives an easy alternative to VGA. If you feel you'd like to look around and learn to use some sort of library, try going here.

(C/C++ FAQ) What compilers do you recommend?

I can't really tell you which are best, for all have their strengths and downfalls. But I have personally found, it is best for a beginner to use a compiler with an IDE, though a lot of people use IDEs, and it has nothing to do with expierience. Therefore, I recommend:

Me, having a fetish for Unix based operating systems, personally use Cygwin. The great thing about Cygwin is, it's not a compiler, but a Unix emulator! Which is great if your coming from Unix to Windows, because, you can use the bash shell, and if you select the option in install, you can get gcc, plus many other widely used Unix applications!

For bare-boned compilers, I have made recommendations toward:

We also have a growing list of compilers on this site.

All my recommendations don't mean anything, this is what I personally have experience with though.

(C/C++ FAQ) The Conversion Specifiers

You may find a troubling thought that says you can't remember the specifier for an integer. For those of you out here...I made a little "chart".

  1. Single Character - %c
  2. Signed Decimal Notation - %d or %i
  3. Float/Double Printed Scientificaly - %e
  4. Float/Double Printed Normally - %f
  5. Prints a Float/Double Scientificaly, or normally based on number - %g
  6. The number of characters converted - %n
  7. Unsigned Octal Notation - %o
  8. Void Pointer Implementation - %p
  9. A String - %s
  10. Unsigned integer printed in decimal notation - %u
  11. Hexadecimal notation printed in lowercase letters - %x
  12. Hexadecimal notation printed in uppercase letters - %X
Those are most of the conversion specifiers, all that I know of anyways. I will put some information on flags that can be used with conversion specifiers later.

---------------------

Also, interpreting C++ programs is like reading a story with no digressions in between. All the logic is hidden in the class implementation, you only see the methods, thus engendering creation of lucid programs.

here is a simple example, although i am not using a class/method scenario, it gives you the idea. // This function swaps two given arguments

-----------
C- Style
-----------
void swap(datatype *ptr1, datatype *ptr2)
{
   datatype temp;
   temp = *ptr1;
        • ptr1 = *ptr2;
        • ptr2 = temp;
}
which you usually call as swap(&var1,&var2);

----------
C++ Style
----------
void swap(datatype & var1, datatype & var2)
{
  datatype temp;
  temp = var1;
  var1 = var2;
  var2 = temp; 
}
which now can be called as swap(var1,var2). Since C++ is downward compatible to most of C features you can still use the former function too.

The C++ code above uses the concept of references, which are aliases to the objects they are associated to (during the function call). When i was learning C and pointers i was scared at the sight of pointers but not now.

(C/C++ FAQ) How should I go about Windows coding?

Well, Windows coding is when all hell breaks loose . If you want to understand the core Windows, then I would try looking up and learning the Win32 API. If you have some cash, you could buy MS VC++ and get the MFC libraries which would make it easier to program in Windows, but MFC can be a monster to code for, and it's object-oriented, so you might wish to stick to something else. There are a hundred different libraries for programming Windows for C/C++, some multi-platform. But still, the API defines the limits, so if you are looking for power, you want API.

I would highly-recommend trying GTK or FLTK.

last edited (October 21, 2006) by bilderbikkel, Number of views: 14369, Current Rev: 28 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.