Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

C/C++ Frequently Asked Questions


  • Please log in to reply
36 replies to this topic

#1 v0id

v0id

    Retired

  • Retired Mod
  • PipPipPipPipPipPipPipPip
  • 2313 posts

Posted 05 August 2008 - 09:02 AM

Before posting make sure to read the board guidelines, and be sure to follow its rules as well.

This thread is meant as another FAQ which is specialized in this forum, the C/C++ forum in particular. If you read this before creating a thread or a post you may avoid asking already frequently asked questions.

I want to learn C/C++, what do I do?
Both C and C++ are so-called compiled languages. That means that programs written in C or C++ will be translated directly into machine code, which can be read directly by your operating system. This translation consists of three steps: compiling, assembling and linking.

The..

compiling process is where the source code is translated in to the assembly language by a compiler. This assembly language can then consist of commands specific to the target processor and architecture.

assembling process is where the new assembly code is translated in to machine code by an assembler. This code is stripped of most data that is not required to run the program (comments, notes, formatting) and is formed as a string of bytes, each byte representing part of, one, or more than one command for the target processor.

linking process is where external libraries are linked in to or included in the program, depending on if it's a dynamic or static library, using a linker. This results in an executable wrapper that the host operating system can initiate the assembled machine code with or a means for another executable to use its functionality by function name rather than byte sequence.


Which tools? tool chains? do I need debuggers?
There are many tools for every C/C++ programmer, and some that can greatly aid in application development. These tools are usually more specialized in specific tasks, such as a profiler for optimization where function calls are logged in real time, a debugger to find memory or application state issues for debugging, or an IDE (integrated development environment) for graphical management of source code and a front-end to compiling processes in one package.

Each one of these are not critical to programming in C, however can be invaluable and worth the effort to learn when you are programming a serious application.

There must be something more than online tutorials.. am I just stuck?
When you have the tools you need to learn the language, such as a compiler toolchain containing all that is necessary to compile, assemble and link, you will need to choose a path of learning.

This can be done in multiple ways. One can learn a lot directly from the internet and the programs on it (such as on SourceForge), and this knowledge can be incorporated in to your own programming, if you understand how it works. If you do not mind investing some money, or need in-depth information and references, a well thought choice is to get your hands on a programming book. Well-reviewed books are often the most appropriate learning material for serious students of programming and build correct coding habits.

Another ambitious choice is to join a programming class or course, either online or at a local institution. In this method you will be able to get feedback and support in a personalised manner, have a structured environment instead of jumping from page to page online, and try out new learning methods in a positive class environment.

Teachers of programming often wind their way on forums such as this too, and so advise found can be a good supplement to a well structured class.


How do I make a driver? ...
... and other questions alike can be impossible for us to answer directly if you are not providing some information about your (operating) system. You must always keep in mind that all systems are different in some manner to a level which may not be apparent to you, and the same code may not work on all systems nor may some suggestions.

This goes for many other so-called platform-dependent questions. If you are not sure whether it's a platform-dependent question, then give us the information you think is necessary (mingw instead of gcc for example, visual studio on a 64 bit system when working with pointers, ...) You are on the secure side, and you do not have to worry about whether users know what you are talking about and do not have to guess giving blanket suggestions.

The search feature is an important too. There are multiple "How do I create an operating system?" threads for example which can be found. Our site strives to index content in a searchable manner with tagging, and is to be used for your benefit.


Is it okay to use conio.h, linux.h or similar? ...
... and questions alike regarding platform-dependent libraries are not really questions for us, but more for yourself. You must consider whether you will use a platform-dependent library or not. The advantage of platform-dependent libraries is that it may have more specialized functionality for your system, or environment, than a platform-independent library, and thus will you have more possibilities. The disadvantage is obviously that platform-dependent libraries do only run on the system or environment it was designed for, so it may not run on other systems. You should especially keep this in mind if you are thinking about making commercial applications.

There is no reason to stop yourself from programming when you find yourself using platform dependent calls, as long as you understand the scope of your project and how you can use alternatives if you are faced with such a situation where you are not able to use them.


Is this tool better than that tool?
This is mostly a matter of taste. Different people prefer different tools. Maybe because it is faster, maybe because it's easier to use, maybe because it looks good, you will see a lot of varying opinions online. If you are asking such a broad question you will end up in the situation similar to researching the tools yourself.

Investigating and collecting information about different tools is a more rewarding solution in that you learn how to use different tools and find out whether they fit your ability and you or not. If you finally end up with two or maybe three tools, and cannot choose, then it is easier to ask for a specific recommendation or experience another user has had based on your specific needs rather than something very general.

The programmer learns to pick up and drop many things during their career.

Is C too old?
You may find people recommending to stay away from C, however it still remains a fundamental language for system programming and can teach you invaluable insights in to how memory management and security come in to play.

C code maps directly in to machine instructions for almost every processor or microcontroller architecture, and can produce minimal and efficient code without the need of existing software to run it. C is a great alternative to coding directly in assembly, however does not provide the programmer with modern tools such as object oriented programming or handled memory on strings or object allocations.

Are the languages being updated at all?
C and C++ as languages are not set in stone, new revisions to provide modernisation are coming by committee or from necessity. Great time will be involved in finalising and integrating the language in to the programming culture or businesses, however looking in to future revisions of standards is important.

Recent standards are given in the form of C(++)(revision by year) and may have incremented after the time of this post.

C11 (2011):

Wikipedia link: http://en.wikipedia....ndard_revision)


What standards do we use now for C?

Usually: C99 (1999)


C++11 (formerly C++0x, for 200x) (2011):

Wikipedia link: http://en.wikipedia.org/wiki/C%2B%2B11


What standards do we use now for C++?

Usually: C++98 or C++03 (1998, 2003)


Some historical versions which should be known to you for use in spotting old code:

K&R C: http://en.wikipedia..../wiki/K&R_C#KRC

ANSI/ISO C: http://en.wikipedia....NSI_C_and_ISO_C

(Note: ANSI and ISO C are outdated C89 (1989) era standards)


Tool/Book Resources:
You can find a list of tools, books, websites, and other general resources for C/C++ in the C/C++ resource thread.

Edited by Alexander, 30 July 2012 - 11:34 PM.
(cleanup of broken censor remnants)

  • 4
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#2 patatas

patatas

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 25 January 2009 - 11:18 AM

Cool stuff here. I have a big project in mind, i will be on touch
  • 0

#3 wiwbiz

wiwbiz

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 66 posts

Posted 01 March 2009 - 03:05 PM


#include <iostream>

using namespace std;

int main(void) {

char c, d=1;

while(std::cin.get(c) && (c!='2' || d!='4') && std::cout.put(d))

d=c;

cin.get();

cin.ignore();

}

Edited by WingedPanther, 06 March 2009 - 08:33 AM.
add code tags (the # button)

  • 0

#4 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 01 March 2009 - 04:36 PM

It really depends on your implementation. In generally, you will probably want a special class to handle that, such as the GNU BigNum library.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#5 curadebt_complaints

curadebt_complaints

    CC Lurker

  • Just Joined
  • Pip
  • 7 posts

Posted 06 March 2009 - 03:21 AM

Yes, You can develop a driver software for your hard ware but you need good practice because their requirements vary from operating system to operating system. It is very flexible and good language to work at lower level but you should have strong logics.
  • 0

#6 neigma34

neigma34

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 06 March 2009 - 05:36 AM

can anybody tell me how to improve my programming skills.
  • 0

#7 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 06 March 2009 - 08:33 AM

neigma: read code, write code, debug code.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#8 neigma34

neigma34

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 06 March 2009 - 10:32 AM

thanxx, for help.

:thumbup1:
  • 0

#9 Edogaa

Edogaa

    CC Newcomer

  • Just Joined
  • PipPip
  • 15 posts

Posted 16 December 2009 - 04:46 PM

Alright, this is gonna be a bit tough to ask


So, what the heck is the IDE, Compiler, and assembler?

At first, since when I took classes I thought the IDE was the same as the compiler or something (Visual Studio's), then I got on linux and downloaded an IDE, and noticed GCC is completely seperate so I wondered if it was a graphical frontend for the compiler. Now I'm not even sure?

On another note I don't exactly know how to program just yet, I can read some of the code, but not exactly understand it fully. I'd like to learn how to program just for the sake of it really, I wouldn't wanted to be limited to one thing. I occasionally want to learn some game programming, but not limit myself to that one thing since it doesn't seem like fun to stick toprogramming to that one thing only. :/

I haven't had much time to refine my skills with school and all sadly. At least not after that semester ended. All we learned to do was go on visual studio's and code random little things that pop-up on screen with random answers to arithmetic problems. Not sure if that makes sense but even if I learned how to read it I didn't feel like I learned much. :/ The book did give me some ideas on how to look at it more so, so which way could I move from here?


Sorry for all the noobish questions, but I kept getting confused by a lot of this. I know its not necessary to know exactly what everything is but I also to be incredibly curious to the point where I Would irritate myself if I Don't know for sure.

Heck I'm not even 100% what a function and class are (albeit I Have some idea, but haven't had the time to look into it with classes, stress, and stuff, I finally have time now that this semester is over though!).
  • 0

#10 CommittedC0der

CommittedC0der

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1065 posts
  • Programming Language:C#
  • Learning:C#, JavaScript, PL/SQL

Posted 16 December 2009 - 04:56 PM

This tells you what a IDE is and a compiler here I couldn't find any thing on assembler though.
  • 0
There IS a war going on for your mind.
Nothing of eternal significance happens besides prayer.

#11 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 16 December 2009 - 05:15 PM

Assembly is a programming language that many languages are translated into before being turned into machine language. It is an extremely low-level programming language.

A compiler is a program that transforms a program from the code you read into machine language. Many compilers translate the programs into assembly as a middle step.

An IDE is an Integrated Development Environment. It's usually the combination of a text editor, front-end for the compiler, and front-end for the debugger. In some case, the IDE is also a RAD (Rapid Application Development) tool. Visual Studio supports this by letting you do drag and drop to design what an application will look like.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#12 Tonyg1

Tonyg1

    CC Newcomer

  • Just Joined
  • PipPip
  • 10 posts

Posted 18 April 2010 - 09:13 AM

I have a question, I have been learning C++ but basically just console programming. I was wondering if anyone can tell me of good books or tutorials on visual programming or windows programing, whatever you want to call it, like dialog boxes and windows, etc. Not sure where to look. Thanks
  • 0