Lecture 17 - Arguments and Sorting

Lecture 17 - Arguments and Sorting - Low bandwidth...

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

View Full Document Right Arrow Icon
17 Command Line Nov. 9, 2006 Announcements • Still catching up on instructor e- mails. • A5 came out Friday (important labs this week). • Code Log starts tonight. • Bonus: not for the faint of heart. Previously • Files – fp = fopen( filename, mode ); • to create/open a file • filename specifies name of file • mode specifies read/write/append • returns pointer to FILE object – fclose( fp ); • closes file that the pointer points to Previously (cont.) • fprintf( fp, format, data ); – prints results (data) to a file specified by fp in the format • fscanf( fp, format, data ); – reads data from a file with given – format Examples • 15_file_write.c • 15_file_read.c The Command Line • The original interface: the command line. • No graphics, no mouse. • Conversational metaphor (teletype)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Advantages • Low tech
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Low bandwidth (accessible over internet) Scriptable Simple Can be very powerful (faster than lots of clicking) Lower level interface Advantages portable stable easy to code Still there today. Communicating With Commands command argument1 argument2 e.g. gcc -Wall -ansi -pedantic a1.c vi a1.c dir format c: Command line arguments in C int main( int argc, char **argv ) argc number of arguments argv array of arguments (of size argc) each argument is char * (I.e. a string) Gotcha! argv[0] is the name of your program! argv[1] is the rst real argument Example 16-arguments.c Sorting Sorting in place Basic operations: compare two elements (which is larger) swap exchange 2 elements...
View Full Document

This note was uploaded on 04/17/2011 for the course CIS 1500 taught by Professor Kramer during the Spring '06 term at University of Guelph.

Page1 / 3

Lecture 17 - Arguments and Sorting - Low bandwidth...

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

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