CSE399 C - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

CSE399 C

Description:

Lecturer: Drew Hilton (adhilton_at_cis) TA: TBA. Lectures: M or W, noon Town 309. Office hours: TBA ... I reserve the right to include in-class quizzes under this ... – PowerPoint PPT presentation

Number of Views:50
Avg rating:3.0/5.0
Slides: 21
Provided by: andrew45
Category:
Tags: cse399 | hilton

less

Transcript and Presenter's Notes

Title: CSE399 C


1
CSE399 - C
  • January 8th, 2007
  • Policies/Hello World

2
Course Info
  • Lecturer Drew Hilton (adhilton_at_cis)
  • TA TBA
  • Lectures M or W, noon Town 309
  • 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

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

5
Grading
  • Homeworks 40
  • Project 40
  • Class attendance/participation 20
  • 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

8
Cheating Policy
  • If I were watching, would you do it?
  • Working in pairs OK
  • 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
Now some C.
  • include
  • include
  • int main (void)
  • printf(Hello World\n)
  • return EXIT_SUCCESS

10
C compilation
11
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)

12
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 /

13
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, )

14
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)

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

16
So whats like Java?
  • Most basic syntax
  • int i
  • int counter 0
  • for ( i 0 i
  • if (xi
  • counter
  • return counter

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

18
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)

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

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