-1

I am a student of computer science and for reasons beyond my comprehension i have only been taught to code in the TURBO compiler.

But now i have realized that i should learn to code in GCC. The problem is that i dont know any of the header files and therefore i am not able to use any of the built in functions.

All the GCC tutorials i have seen are for beginners. I am at more of an intermediate state of learning and hence if any of you know of a book or a website where i can learn the details about the header files then it would be helpful.

NOTE: just to be clear-i am a linux user.

  • 4
    You dont code in GCC. You compile with GCC. Header files have nothing to do with GCC they are language specific. – pnezis Nov 16 '11 at 14:57
  • 1
    I get the impression that Turbo C is very popular in CS courses in India. Pretty much all the questions about it here on Stack Overflow come from students at Indian universities. – Oliver Charlesworth Nov 16 '11 at 14:59
  • @webclectic: Alas, not so simple. Turbo C is massively outdated, so its support of the C++ standard and the standard library is significantly impaired. – Oliver Charlesworth Nov 16 '11 at 15:00
  • @webclectic: okay. I want to compile a C program using GCC. So i need to know the header files. For eg: TURBOC has a header file called time.h which contains functions dealing with timing your code. How do i find an equivalent here? –  Nov 16 '11 at 15:02
  • @OliCharlesworth :yes. :) it is favoured to the exclusion of all other C compilers and as you said it is massively outdated. –  Nov 16 '11 at 15:06
  • 1
    @ChaitanyaNettem: Your reasoning is flawed, though: You need to know the haader files if you want to **learn C**, not because you want to use the GCC compiler. The distinction is crucial. – Kerrek SB Nov 16 '11 at 15:09

4 Answers4

0

Most of the header files used by gcc are either C C++ or POSIX compliant. Therefore you need to learn the language. printf is in stdio.h in every C compiler that is standards compliant.

There are specific linux ones but you probably dont care about those. If you ware using a linux system the 'man' command is your friend - but it tells you the header file.

 man 3 printf

produces

NAME
   printf, fprintf, sprintf, snprintf, vprintf, vfprintf, vsprintf, vsnprintf - formatted output conversion

 SYNOPSIS
   #include <stdio.h>
 ....
Adrian Cornish
  • 23,227
  • 13
  • 61
  • 77
  • But there are differences. To create text user interfaces and to control them you have to use the conio.h header file in Turbo. Whereas i am told the same is done using ncurses in gcc. So how do i learn about these differences? –  Nov 16 '11 at 15:21
0

Like if you want to use printf() (for eg..), just type man printf (man stands for manual) in your terminal if Linux or in google and you'l get all the thing you need to use printf:

Synopsis

#include <stdio.h>
int printf (const char *format, ...); 
int fprintf (FILE *stream, const char *format, ...); 
int sprintf (char *str, const char *format, ...); 
int snprintf (char *str, size_t size, const char *format, ...);

#include <stdarg.h>

int vprintf (const char *format, va_list ap); 
int vfprintf (FILE *stream, const char *format, va_list ap); 
int vsprintf (char *str, const char *format, va_list ap); 
int vsnprintf (char *str, size_t size, const char *format, va_list ap);

Then to use printf(), you see that you need to include stdio.h:

#include <stdio.h>

Normally you can compile without including it but it gives you warning..

Moreover use <> to include standart header files and "" to include your headers like: #include "myHeaderinMyLocalFolder.h"

GrandMarquis
  • 1,913
  • 1
  • 18
  • 30
0

If TURBO-C (which I guess you meant) is anything like TURBO-PASCAL, with it's library of console functions, there is nothing like that in standard C. And standard C is what is usedby gcc, so if you know how to use the functions in e.g. stdio.h then there is not much difference.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621