lecture 20 week6

lecture 20 week6 - Unix C + GNU HTML Perl Python Teacher's...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal Software Systems 1 Teacher's Notes
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal Software Systems 2 Comp-206 : Introduction to Software Systems Week 6 Joseph Vybihal Computer Science McGill University
Background image of page 2
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal Software Systems 3 Announcements
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal Software Systems 4 Part 1 C’s Standard Libraries
Background image of page 4
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal Software Systems 5 About Libraries They are made from 2 files: .h .o (originally .c or .assembler file) The .o files are often merged (like a zip) into a single file called a: .lib, or .dll .lib files are merged into your program .dll files are merged into the OS and called/shared by all programs.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal Software Systems 6 Linking .lib Files gcc –c file.c file2.c gcc –o outfile file.o file2.c
Background image of page 6
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal Software Systems 7 GCC and Libraries Two steps to use libraries Step 1: Compiler needs to know about them C's Standard Library the LIB directory This is default (so nothing to do, automatic) Invoking external libaries through GCC Gcc file.c -l library gcc -I/opt/gdbm/include dbmain.c /opt/gdbm/lib/libgdbm.a Step 2: You need to ask to use them #include <standard c library> or #include “path/external c library”
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal Software Systems 8 Many Libraries #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <ctype.h> Many more come standard in C Many more designed special for your compiler Many more can be purchased .h simply refers to a “header” file. It is basically the same as a .c file but with the extension .h to indicate that it gets included by another file. Normally .h is used for files that have common info needed by many .c files.
Background image of page 8
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal Software Systems 9 #include <string.h>
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal Software Systems 10 String Functions int strcmp(char *s1, char*s2) int strncmp(char *s1, char*s2, int len) int strlen(char *string) char *strcpy(char *dest, char*src) … strncpy char *strcat(char *dest, char*src) … strncat void *memset(char* string, char character, int len) Some random examples. .. Char * vs. char array[]
Background image of page 10
Unix C + GNU HTML Perl Python COMP 206 - Joseph Vybihal Software Systems 11 #include <string.h> void *memccpy(void *restrict, const void *restrict, int, size_t); void *memchr(const void *, int, size_t); int memcmp(const void *, const void *, size_t); void *memcpy(void *restrict, const void *restrict, size_t); void *memmove(void *, const void *, size_t); void *memset(void *, int, size_t); char *strcat(char *restrict, const char *restrict);
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 51

lecture 20 week6 - Unix C + GNU HTML Perl Python Teacher's...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online