CSE399 - C - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

CSE399 - C

Description:

I reserve the right to include in-class quizzes under this ... Compile with cygwin or other compiler? Copy to eniac-l to test. Homework 1. On webpage now ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 24
Provided by: andrew45
Category:
Tags: cse399 | cygwin

less

Transcript and Presenter's Notes

Title: CSE399 - C


1
CSE399 - C
  • January 16th, 2008
  • Policies/Hello World

2
Course Info
  • Lecturer Drew Hilton (adhilton_at_cis)
  • TA TBA
  • Lectures W, noon Town 321
  • Office hours TBA
  • Webpage
  • www.seas.upenn.edu/adhilton/cse399

3
Overview
  • C/C
  • Somewhat flexible on topics
  • Assuming you are eager to learn this
  • Last semesters grades
  • A 68
  • B 29
  • C-F 3

4
Textbook
  • No required textbook
  • Google
  • man pages
  • 2006s book
  • C for Java Programmers
  • By Mark A. Weiss

5
Grading
  • Homeworks 30
  • Project 40
  • Exam 20
  • 3/4 term- later than a midterm, but not a final
  • Class attendance/participation 10
  • I reserve the right to include in-class quizzes
    under this category if I feel it is needed

6
Homeworks
  • 1-2 weeks each
  • Equally weighted
  • Partner optional
  • Due at start of class
  • 5 grace days, then 20 pts/day
  • Grading will be done on eniac-l

7
Project
  • Large program
  • 1-3 people (pairs encouraged)
  • Due at end of semester
  • Propose topic before Spring Break
  • Last years projects
  • Games Tetris, Connect 4, etc
  • Financial Modeling
  • Command shell with meta data in a DB

8
Cheating Policy
  • If I were watching, would you do it?
  • Working in pairs OK (encouraged!)
  • Both partners must participate/learn
  • Pair programming
  • Separate code, debugging help etc
  • Document who/how in comments
  • Only your partner should see your code
  • When in doubt ask me

9
C/C assuming Java
  • I assume you know how to program
  • In Java
  • Know basic programming
  • Familiar with syntax (based on C)
  • Understand OO concepts
  • If not Java, then C?
  • Probably need to brush up on OO
  • Can still learn from first part of course
  • None of the above? See me after class

10
Now some C.
  • include ltstdlib.hgt
  • include ltstdio.hgt
  • int main (void)
  • printf(Hello World\n)
  • return EXIT_SUCCESS

11
C compilation
12
Whats in a header?
  • Preprocessor definition
  • define EXIT_SUCCESS 0
  • Function prototypes
  • Declare the argument/return types
  • Example
  • int factorial(int x)
  • Note ends in semi-colon.
  • External variable declarations (later)
  • Type declarations (also later)

13
A first approximation
  • / maybe this is the prototype from stdio?/
  • void printf(string x)
  • int main (void)
  • printf(Hello World\n)
  • return 0 / Replace defined symbol /

14
Close, but
  • C doesnt have a string type
  • char represents a sequence of characters
  • printf actually
  • Returns int (number of characters printed)
  • Takes a variable number of arguments
  • int printf(char format, )

15
A variable number of arguments?
  • First arg format specifier string
  • Contains directives (d, s, )
  • Later args values to replace directives
  • Example
  • int x 3
  • char s some string
  • printf(x is d and s is s \n, x, s)

16
Basically right
  • int printf(char format, )
  • int main (void)
  • printf(Hello World\n)
  • return 0
  • (Actually, lots of other stuff defined in those
    headers)

17
Two types of include
  • include ltstdio.hgt
  • Use angle brackets for system files
  • include myheader.h
  • Use quotes for header files in the local
    directory (i.e. that you wrote/were provided)

18
So whats like Java?
  • Most basic syntax
  • int i
  • int counter 0
  • for ( i 0 i lt 10 i )
  • if (xi lt yi)
  • counter
  • return counter

19
Caveat
  • What about
  • for (int i 0 i lt 10 i )
  • Error for loop initital declaration used
    outside C99 mode
  • Solution compile with -stdc99

20
Arrays somewhat similar
  • Indexed the same xi
  • Not objects dont have length field
  • Just contiguos regions of memory
  • Accesses not bounds checked
  • Dynamic allocation is different
  • (more on this later)

21
Editing/compiling code
  • ssh guide on class webpage how to login
  • Editing
  • On eniac-l
  • Emacs guide on web
  • Other editor of your choice on your own
  • On your computer your choice of editor
  • Compile with cygwin or other compiler?
  • Copy to eniac-l to test.

22
Homework 1
  • On webpage now
  • Due Wed Jan 30th at noon by email
  • Probably lt 40 minutes
  • Get acquainted with Javalike parts of C
    discussed today
  • Questions? email me.

23
Questions?
Write a Comment
User Comments (0)
About PowerShow.com