Basic primer on how to use GCC

Basic primer on how to use GCC

Post by George Maren » Sun, 08 Nov 1998 04:00:00



I'm looking for info about how to start using gcc - no previous
programming experience.
 
 
 

Basic primer on how to use GCC

Post by Gary Momariso » Sun, 08 Nov 1998 04:00:00



> I'm looking for info about how to start using gcc - no previous
> programming experience.

You'll find some links to C/C++ tutorials, etc. in the "languages"
page of Gary's Encyclopedia at htpp://www.aa.net/~swear/languages.html

I don't know that any of them cover gcc, but they might help anyway.
You might see if www.gnu.org has anything to offer.

 
 
 

Basic primer on how to use GCC

Post by david kahan » Mon, 09 Nov 1998 04:00:00



> I'm looking for info about how to start using gcc - no previous
> programming experience.

Save the attached code in start_gcc.c, and do:

gcc start_gcc.c -o start_gcc -lm
start_gcc

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

#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define LINESIZE 80

int main (int argc, char **argv) {

  FILE *outfile;

  int i, count;
  double x, dx, y;

  char line[LINESIZE];
  char *name;

  if(argc != 1) {
    printf("Usage: start_gcc\n");
    exit(-1);
  }

  if( (outfile = fopen("cosine.out", "w")) == (FILE *) NULL) {
    printf("Couldn't open output file.\n");
    exit(-2);
  }

  printf("Hello there! My name is start_gcc.\n\n");
  printf("What is your name?  ");

  if(fgets(line, LINESIZE, stdin) == (char *) NULL) {
    printf("Error reading your name!\n");
    exit(-3);
  }

  name = strtok(line, "\n");

  printf("\n");

  printf("Glad to meet you %s!\n\n", name);
  printf("I am doing a few calculations just to show you that I can.\n");
  printf("The results will appear in the file cosine.out.\n\n");

  x = 0.0;
  dx = 0.1;

  fprintf(outfile, "Here is a short table of the values of cosine:\n");

  for(i=0; i<1000; i++) {
        x += dx;
        y = cos(x);
        fprintf(outfile, "%f %f\n", x, y);
  }

  printf("Congratulations! You have successfully compiled and run this\n");
  printf("rather silly program, and have completed the basic primer on how to\n");
  printf("use gcc. Some programs can be a bit more complicated than this,\n");
  printf("but basically you are well on your way. For additional info try:\n");
  printf("man gcc.\n\n");
  printf("For information on C try: Practical C Programming,\n");
  printf("by Steve Oualline, (O'Reilly & Associates)\n\n");
  printf("For information on C++ try: C++ The Core Language,\n");
  printf("by Gregory Satir and Doug Brown, (O'Reilly & Associates)\n\n");
  printf("There is also a very complete book on gcc itself by Richard Stallman:\n");
  printf("Using and porting GCC for version 2.8, but it costs US $50\n\n");
  printf("For good descriptions of C-library functions: fire up emacs\n");
  printf("and check out the info pages. (Ctrl-h i)\n\n");
  printf("cheers,\n\n");
  printf("- dave k.\n");

  fclose(outfile);

Quote:}

 
 
 

1. basic security primer, anyone?

I am trying to put together a basic security primer outlining the varius
forms of attack (from phycial to electronic) on a system.  This is for a
non-technical audience.

Also policies for prevention of such as might be used by a small company.

Does anyone know of anything like that on the web?

Thanks,

--Yan

2. GIMP

3. getchar with gcc using pointers --using gcc not any other compiler

4. Linux doesn't recognise my mfm-controller

5. Primer for (potential) FreeBSD converts who are used to Linux?

6. IPMasq & Speed

7. using basic unix for everyday uses

8. Get StarOffice 6.0

9. problem compiling using -D__USE_MALLOC using gcc-2.95.2 on aix 4.3.3

10. newbie to gcc/g++ on Linux needs basic template help

11. GCC: basic setup question

12. Basic GCC++ Question.

13. GCC: basic setup question