Wed May 8 15:45:02 2024
EVENTS
 FREE
SOFTWARE
INSTITUTE

POLITICS
JOBS
MEMBERS'
CORNER

MAILING
LIST

NYLXS Mailing Lists and Archives
NYLXS Members have a lot to say and share but we don't keep many secrets. Join the Hangout Mailing List and say your peice.

DATE 2008-06-01

HANGOUT

2024-05-08 | 2024-04-08 | 2024-03-08 | 2024-02-08 | 2024-01-08 | 2023-12-08 | 2023-11-08 | 2023-10-08 | 2023-09-08 | 2023-08-08 | 2023-07-08 | 2023-06-08 | 2023-05-08 | 2023-04-08 | 2023-03-08 | 2023-02-08 | 2023-01-08 | 2022-12-08 | 2022-11-08 | 2022-10-08 | 2022-09-08 | 2022-08-08 | 2022-07-08 | 2022-06-08 | 2022-05-08 | 2022-04-08 | 2022-03-08 | 2022-02-08 | 2022-01-08 | 2021-12-08 | 2021-11-08 | 2021-10-08 | 2021-09-08 | 2021-08-08 | 2021-07-08 | 2021-06-08 | 2021-05-08 | 2021-04-08 | 2021-03-08 | 2021-02-08 | 2021-01-08 | 2020-12-08 | 2020-11-08 | 2020-10-08 | 2020-09-08 | 2020-08-08 | 2020-07-08 | 2020-06-08 | 2020-05-08 | 2020-04-08 | 2020-03-08 | 2020-02-08 | 2020-01-08 | 2019-12-08 | 2019-11-08 | 2019-10-08 | 2019-09-08 | 2019-08-08 | 2019-07-08 | 2019-06-08 | 2019-05-08 | 2019-04-08 | 2019-03-08 | 2019-02-08 | 2019-01-08 | 2018-12-08 | 2018-11-08 | 2018-10-08 | 2018-09-08 | 2018-08-08 | 2018-07-08 | 2018-06-08 | 2018-05-08 | 2018-04-08 | 2018-03-08 | 2018-02-08 | 2018-01-08 | 2017-12-08 | 2017-11-08 | 2017-10-08 | 2017-09-08 | 2017-08-08 | 2017-07-08 | 2017-06-08 | 2017-05-08 | 2017-04-08 | 2017-03-08 | 2017-02-08 | 2017-01-08 | 2016-12-08 | 2016-11-08 | 2016-10-08 | 2016-09-08 | 2016-08-08 | 2016-07-08 | 2016-06-08 | 2016-05-08 | 2016-04-08 | 2016-03-08 | 2016-02-08 | 2016-01-08 | 2015-12-08 | 2015-11-08 | 2015-10-08 | 2015-09-08 | 2015-08-08 | 2015-07-08 | 2015-06-08 | 2015-05-08 | 2015-04-08 | 2015-03-08 | 2015-02-08 | 2015-01-08 | 2014-12-08 | 2014-11-08 | 2014-10-08 | 2014-09-08 | 2014-08-08 | 2014-07-08 | 2014-06-08 | 2014-05-08 | 2014-04-08 | 2014-03-08 | 2014-02-08 | 2014-01-08 | 2013-12-08 | 2013-11-08 | 2013-10-08 | 2013-09-08 | 2013-08-08 | 2013-07-08 | 2013-06-08 | 2013-05-08 | 2013-04-08 | 2013-03-08 | 2013-02-08 | 2013-01-08 | 2012-12-08 | 2012-11-08 | 2012-10-08 | 2012-09-08 | 2012-08-08 | 2012-07-08 | 2012-06-08 | 2012-05-08 | 2012-04-08 | 2012-03-08 | 2012-02-08 | 2012-01-08 | 2011-12-08 | 2011-11-08 | 2011-10-08 | 2011-09-08 | 2011-08-08 | 2011-07-08 | 2011-06-08 | 2011-05-08 | 2011-04-08 | 2011-03-08 | 2011-02-08 | 2011-01-08 | 2010-12-08 | 2010-11-08 | 2010-10-08 | 2010-09-08 | 2010-08-08 | 2010-07-08 | 2010-06-08 | 2010-05-08 | 2010-04-08 | 2010-03-08 | 2010-02-08 | 2010-01-08 | 2009-12-08 | 2009-11-08 | 2009-10-08 | 2009-09-08 | 2009-08-08 | 2009-07-08 | 2009-06-08 | 2009-05-08 | 2009-04-08 | 2009-03-08 | 2009-02-08 | 2009-01-08 | 2008-12-08 | 2008-11-08 | 2008-10-08 | 2008-09-08 | 2008-08-08 | 2008-07-08 | 2008-06-08 | 2008-05-08 | 2008-04-08 | 2008-03-08 | 2008-02-08 | 2008-01-08 | 2007-12-08 | 2007-11-08 | 2007-10-08 | 2007-09-08 | 2007-08-08 | 2007-07-08 | 2007-06-08 | 2007-05-08 | 2007-04-08 | 2007-03-08 | 2007-02-08 | 2007-01-08 | 2006-12-08 | 2006-11-08 | 2006-10-08 | 2006-09-08 | 2006-08-08 | 2006-07-08 | 2006-06-08 | 2006-05-08 | 2006-04-08 | 2006-03-08 | 2006-02-08 | 2006-01-08 | 2005-12-08 | 2005-11-08 | 2005-10-08 | 2005-09-08 | 2005-08-08 | 2005-07-08 | 2005-06-08 | 2005-05-08 | 2005-04-08 | 2005-03-08 | 2005-02-08 | 2005-01-08 | 2004-12-08 | 2004-11-08 | 2004-10-08 | 2004-09-08 | 2004-08-08 | 2004-07-08 | 2004-06-08 | 2004-05-08 | 2004-04-08 | 2004-03-08 | 2004-02-08 | 2004-01-08 | 2003-12-08 | 2003-11-08 | 2003-10-08 | 2003-09-08 | 2003-08-08 | 2003-07-08 | 2003-06-08 | 2003-05-08 | 2003-04-08 | 2003-03-08 | 2003-02-08 | 2003-01-08 | 2002-12-08 | 2002-11-08 | 2002-10-08 | 2002-09-08 | 2002-08-08 | 2002-07-08 | 2002-06-08 | 2002-05-08 | 2002-04-08 | 2002-03-08 | 2002-02-08 | 2002-01-08 | 2001-12-08 | 2001-11-08 | 2001-10-08 | 2001-09-08 | 2001-08-08 | 2001-07-08 | 2001-06-08 | 2001-05-08 | 2001-04-08 | 2001-03-08 | 2001-02-08 | 2001-01-08 | 2000-12-08 | 2000-11-08 | 2000-10-08 | 2000-09-08 | 2000-08-08 | 2000-07-08 | 2000-06-08 | 2000-05-08 | 2000-04-08 | 2000-03-08 | 2000-02-08 | 2000-01-08 | 1999-12-08

Key: Value:

Key: Value:

MESSAGE
DATE 2008-06-28
FROM Ruben Safir
SUBJECT Subject: [NYLXS - HANGOUT] C Programing Workshop
The C programming language was invented side by side with Unix. The King text goes through
much of the history of the language. Here I'd like to make a few points both in the general
and specific to GNU/Linux as a platform for C development.

Oxymoronic as it sounds C language is a bare bones specification without anything useful.
All it requires is the keyword main, which defines the root function that everything else
is piled into. Everything that C does is imported from external libraries. These libraries
are defined, in the simplist case, on top of your program.

For example, on page 10 of the King book is the following program:

#include

main(){
printf("To C, or not to C: that is the question \n");
}

which was inherited from the K&R text. The first line defines the
library stdio.h which c is to import. The main keyword is present
(which defines the required function main() to be explained later,
and the function printf which is defined in the library stdio.h.

Unlike programming languages such as Perl, Python and Rudy, C is a compiled
programming language. It needs a compiler to make a binary program that
can then be executed. The binary has machine like instructions which your
computer can directly understand. Unfortunately, your computer doesn't speak
English (or Spanish, Russian, Japanese, Manderin, Hebrew, or Udo). It speaks
binary. C is the interface between human language and machine code. The binaries
are very low level and C as a language, today, is considered to be very close to
the machine. You'd have to write programs in Assembly to get much close to your CPU.

Therefor, you need a C compiler to translate your C Programming text into machine code.
At one time suc compilers were expensive and hard to get. Thanks to Richard Stallman and
friends, today we have compilers on almost every GNU based system. That compiler is called
gcc. Compilers do three things: Parse, compile and link.

When you call:

gcc file.c

It loads file.c into the compiler. It then parses the programming you created and checks
for errors. It then analysis the symbols in your program and looks for their programming
definitions in the libraries that you call with #include. It then the different code
machine code peices it finds into a single binary.

The gcc compiler is very complex and learning C includes learning much about the compiler
and also the debugger, called gdb. Both are documented with man pages, and have full books
which are available from the Free Software Foundation and worthy additions to your library.
Both are included in the NYLXS library as references.

Any editor can be used to make C programs, but I strongly recommend learning either EMACS
or VI. EMACS has a GNU version, and VI has a version called VIM which can be downloaded and
used. I perfer the VIM editor and will use in in example and demonstrations. No editor
wars are needed here. I will say, however, if your using EMACS, then LEARN it. It is not
Microsoft Notepad.

After editing this first program run the following command on the command line:
For this workshop, the "$" or "ruben-at-www2:~/cprog>" is the shell prompt. Your prompt
on the NYLXS server will look like the second example.


$ gcc -Wall file1.c -o file1

the output will look like this:
ruben-at-www2:~/cprog> gcc -Wall file1.c -o file1
file1.c:3: warning: return type defaults to `int'
file1.c: In function `main':
file1.c:5: warning: control reaches end of non-void function
ruben-at-www2:~/cprog>


The compiler gives you 3 warning messages. I won't go into them currently, but in a few
weeks it should make sense to you. We will, however, fix the warnings later. For now, if
you look at your directory

ruben-at-www2:~/cprog> ls -l
total 12
-rwxr-xr-x 1 ruben staff 7041 2008-06-28 21:45 file1
-rw-r--r-- 1 ruben staff 86 2008-06-28 21:35 file1.c

file1.c is the file we are editing. You see it has no permisions to be executed.
file1 is the new executable we created. In addition. you see that it is executable.
gcc makes it executable permisions for us in most systems. We run our new program
on the command line like this:

ruben-at-www2:~/cprog> ./file1
To C, or not to C: that is the question

The C language defines the function main() and not much else. However, it is defined
as a function that returns an integer. We didn't return anything. We can fix this with
a "return function".

We return a 0 by convention unless we are trying to indicate an error or other message. We also
put the keyword 'int' infront of main which explicitly defines that main returns integers.

Our program not looks like this:

#include

int main(){
printf("To C, or not to C: that is the question \n");
return 0;
}

and when we compile:

ruben-at-www2:~/cprog> gcc -Wall file2.c -o file2
ruben-at-www2:~/cprog>

No warnings.

and when we run it, it looks like this:

ruben-at-www2:~/cprog> ./file2
To C, or not to C: that is the question
ruben-at-www2:~/cprog>



Next - Comments and C varriable basics.



--
http://www.mrbrklyn.com - Interesting Stuff
http://www.nylxs.com - Leadership Development in Free Software

So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998

http://fairuse.nylxs.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002

"Yeah - I write Free Software...so SUE ME"

"The tremendous problem we face is that we are becoming sharecroppers to our own cultural heritage -- we need the ability to participate in our own society."

"> I'm an engineer. I choose the best tool for the job, politics be damned.<
You must be a stupid engineer then, because politcs and technology have been attached at the hip since the 1st dynasty in Ancient Egypt. I guess you missed that one."

© Copyright for the Digital Millennium

  1. 2008-06-03 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [nyc-at-workatjelly.com: Jelly in Manhattan this Friday, 6/6]
  2. 2008-06-08 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Empathic Computing
  3. 2008-06-08 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] GMAIL - Free Software Models
  4. 2008-06-08 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Cellphone DO kill ....
  5. 2008-06-08 Michael L Richardson <mlr52-at-michaellrichardson.com> Re: [NYLXS - HANGOUT] Cellphone DO kill ....
  6. 2008-06-08 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Bloody Ugly
  7. 2008-06-12 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [nyc-at-workatjelly.com: Jelly in Brooklyn this Friday, 6/13]
  8. 2008-06-12 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [notification+zjaayj4y-at-facebookmail.com: "The Rooftop Films Summer Series: June Schedule" sent you a message on Facebook...]
  9. 2008-06-12 From: "armando fonseca" <afonsec2-at-gmail.com> Subject: [NYLXS - HANGOUT] armando fonseca wants to chat
  10. 2008-06-20 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [KMalhotra-at-council.nyc.gov: Tech in Government Update]
  11. 2008-06-20 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [meissner-at-suse.de: [security-announce] SUSE Security Announcement: evolution (SUSE-SA:2008:028)]
  12. 2008-06-20 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [dplist-at-danielpipes.org: #862: Pipes argues "The Enemy Has a Name" in the Jer. Post]
  13. 2008-06-20 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [meissner-at-suse.de: [security-announce] SUSE Security Summary Report SUSE-SR:2008:013]
  14. 2008-06-20 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [meissner-at-suse.de: [security-announce] SUSE Security Announcement: Opera 9.50 (SUSE-SA:2008:029)]
  15. 2008-06-20 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [chief-at-freesoftwaremagazine.com: [Fsm_newsletter] Free Software Magazine newsletter]
  16. 2008-06-20 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [anthony.weiner-at-congressnewsletter.net: Reminder - Town Hall with Rep. Weiner]
  17. 2008-06-20 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Geek Dinosaur News
  18. 2008-06-20 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] More Geek stuff - 2000 year old Jew Tree's
  19. 2008-06-21 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] AP Copyright and Bloggers
  20. 2008-06-21 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Diamonds are a girls best friend
  21. 2008-06-22 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [jays-at-panix.com: [nylug-talk] Sunday 22 June 2008 NYC Resistors: OLPC Hack Day]
  22. 2008-06-22 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Tea Lounge
  23. 2008-06-22 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Next NYLXS Meeting
  24. 2008-06-22 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [ruben-at-mrbrklyn.com: [nylug-talk] Internships for Teens?]
  25. 2008-06-22 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] OLPC MS Spin
  26. 2008-06-23 From: "Michael L. Richardson" <mlr52-at-mycouponmagic.com> Re: [NYLXS - HANGOUT] Next NYLXS Meeting
  27. 2008-06-23 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [catch152-at-gmail.com: Re; Signing up.]
  28. 2008-06-23 Amy Coleman <acoleman-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] Next NYLXS Meeting
  29. 2008-06-23 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Some Brooklyn History with Photo's! Worth a look.
  30. 2008-06-24 Ron Guerin <ron-at-vnetworx.net> Re: [NYLXS - HANGOUT] Tea Lounge
  31. 2008-06-24 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [nyc-at-workatjelly.com: Jelly in Brooklyn this Friday, 6/27]
  32. 2008-06-24 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] Tea Lounge
  33. 2008-06-24 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [Consultants1-at-cgt-consult.com: Open Jobs]
  34. 2008-06-24 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Data Recovery Tools
  35. 2008-06-26 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] News not getting enough press
  36. 2008-06-28 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] Video Production
  37. 2008-06-28 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] The new DMCA
  38. 2008-06-28 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] On Line C, Perl and C++ Programming Work Shop
  39. 2008-06-28 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] C Programing Workshop
  40. 2008-06-29 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] [ivaldes-at-hal-pc.org: [Hardhats] Congress Health IT Bill and Cerner Lobbying]y
  41. 2008-06-29 From: "Ronny Abraham" <ronny.coder-at-gmail.com> Re: [NYLXS - HANGOUT] C Programing Workshop
  42. 2008-06-29 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] C Programing Workshop
  43. 2008-06-29 From: "Ronny Abraham" <ronny.coder-at-gmail.com> Re: [NYLXS - HANGOUT] C Programing Workshop
  44. 2008-06-29 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] C Programing Workshop
  45. 2008-06-29 From: "Michael L. Richardson" <mlr52-at-michaellrichardson.com> Re: [NYLXS - HANGOUT] Video Production
  46. 2008-06-29 email <ray-pub-at-rcn.com> Re: [NYLXS - HANGOUT] C Programing Workshop
  47. 2008-06-29 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [NYLXS - HANGOUT] C++ Workshop session 1
  48. 2008-06-30 From: "Ronny Abraham" <ronny.coder-at-gmail.com> Re: [NYLXS - HANGOUT] C Programing Workshop
  49. 2008-06-30 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] C Programing Workshop
  50. 2008-06-30 swd <sderrick-at-optonline.net> Subject: [NYLXS - HANGOUT] Need to get rid of a whole bunch of programming books. TALK ABOUT FREE
  51. 2008-06-30 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] Need to get rid of a whole bunch of programming books. TALK ABOUT FREE SOFTWARE!!!
  52. 2008-06-30 From: "Tameek Henderson" <tameek-at-gmail.com> Re: [NYLXS - HANGOUT] Need to get rid of a whole bunch of programming books. TALK ABOUT FREE SOFTWARE!!!
  53. 2008-06-30 Ruben Safir <ruben-at-mrbrklyn.com> Re: [NYLXS - HANGOUT] Need to get rid of a whole bunch of programming books. TALK ABOUT FREE SOFTWARE!!!

NYLXS are Do'ers and the first step of Doing is Joining! Join NYLXS and make a difference in your community today!