C Queries

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2008
Posts: 8
Reputation: Ninad16 is an unknown quantity at this point 
Solved Threads: 0
Ninad16 Ninad16 is offline Offline
Newbie Poster

C Queries

 
0
  #1
Oct 18th, 2008
Hi all,

Just started learning C.I have some basic queries.They may sound silly to you.But please bear with me.

-What is the difference between Linking,Runtime and Compilation Error?
-What does getchar() actually do?
-How do turbo C++ and Visual C++ compilers differ from each other?I mean...in what aspects?Do C functions like printf(),etc. give different outputs when compiler is changed?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 273
Reputation: Sci@phy will become famous soon enough Sci@phy will become famous soon enough 
Solved Threads: 42
Sci@phy's Avatar
Sci@phy Sci@phy is offline Offline
Posting Whiz in Training

Re: C Queries

 
3
  #2
Oct 18th, 2008

  1. First you write code in some text editor. It doesn't matter what editor, it could even be notepad.
    Then you have to compile that code.
    Compilation refers to the processing of source code files (.c, .cc, or .cpp) and the creation of an 'object' file. This step doesn't create anything the user can actually run. Instead, the compiler merely produces the machine language instructions that correspond to the source code file that was compiled. read for more
    Compilation error is therefore something that occured during this phase, most likely syntax error (misspelled some function name, or trying to do something that C doesn't allow)

    So, after compilation, you have object files. In simple programs you have only one object file, so it's difficult to understand need for it (why not just build everything at once?).
    But if you have more different files that you want to merge into one program, first you have to compile every single one into object.
    Then it's linker's job to take all object files and to make executable out of it.
    Linker error is most likely definition/declaration error (you can have function defined in one file, and declared in another. If these two aren't identical linker error occurs).

    Runtime error 99% of the time has to do with evil horrible pointers. It happens at the time program is working, and therefore, the mistake cannot be located so easily.
    Mostly has to do with program trying to acces/alter forbidden memory, OR program altering memory it should not!

  2. char getchar(void); Returns one character from stdin buffer (a.k.a. your keyboard)

  3. They differ a lot, since turbo c++ compiler is ANCIENT.
    There is something that is called standard C++ language. It wasn't fully defined at turbo c++ time, so some things that were differently defined don't work nowadays.
    My advice is: don't go with turbo c++, get some new compilers.
    And try not to use c++ compilers, although they should work with C
    To answer specific question: printf() is the same as before.
Last edited by Sci@phy; Oct 18th, 2008 at 2:23 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: C Queries

 
0
  #3
Oct 19th, 2008
Originally Posted by Sci@phy View Post
They differ a lot, since turbo c++ compiler is ANCIENT.
There is something that is called standard C++ language. It wasn't fully defined at turbo c++ time, so some things that were differently defined don't work nowadays.
But, for a new student, these differences can be minor. I rarely have a problem switching from one to the other. (maybe I just know too much)

Originally Posted by Sci@phy View Post
And try not to use c++ compilers, although they should work with C
I am unaware of any compilers that are C only designed in the last 18-20 years, especially based on the recommendation to get a new compiler. Virtually all compilers today are C++ compilers and, since C++ is (guestimate) 75% or more C, they all compile C without problems.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 273
Reputation: Sci@phy will become famous soon enough Sci@phy will become famous soon enough 
Solved Threads: 42
Sci@phy's Avatar
Sci@phy Sci@phy is offline Offline
Posting Whiz in Training

Re: C Queries

 
0
  #4
Oct 19th, 2008
Originally Posted by WaltP View Post
I am unaware of any compilers that are C only designed in the last 18-20 years, especially based on the recommendation to get a new compiler. Virtually all compilers today are C++ compilers and, since C++ is (guestimate) 75% or more C, they all compile C without problems.
Will turbo C++ allow C99 standard things? If it compiles C code, not C++.
(I don't know if a turbo c++ compiler can compile C like plain C or it compiles it as C++?)
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,749
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 739
Team Colleague
Narue's Avatar
Narue Narue is online now Online
Code Goddess

Re: C Queries

 
1
  #5
Oct 20th, 2008
>Will turbo C++ allow C99 standard things?
Most modern compilers don't compile C99. It's not a popular enough standard even to be completely implemented, much less widely implemented. You'll be hard pressed to find a C++ compiler that isn't very stable with C89 though, provided you pass it the right switches to compile as C instead of C++.

>I am unaware of any compilers that are C only designed in the last 18-20 years
LCC Win32 is strictly C, and is being actively developed with the goal of C99 conformance.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC