Thinking in C and *nix (CSC 295/282 2014S) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [Teaching & Learning] - [Calendar]
Current: [Outline] [EBoard] [Reading] [Lab] [Assignment]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines]
Reference: [EBook] - [ISO] [GNU Coding Standards] [GCC Documentation] - [TAoUP] [Make3]
Related Courses: [CSC 295 2013S]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker]
Overview
Three primary approaches
Good programming practices
Good C programmers
run CRASH bt
Thinking like a *nix programmer
char *
fun (char *t, char *s)
{
while (*t++ = *s++);
return t;
} // fun
This function copies s to to. It's mostly strcpy. It returns a pointer to the one after the end-of-string character in the result.
x = malloc (...);
foo ();
bar ();
free (x); // CRASH
If you know awk, you could write an awk script to do it. (less than a minute, if you know awk and use it regularly)
If you know flex, you can write a flex program. (five minutes)
If you program regularly in C (which we'll assume, write a C program).
(five to ten minutes).
int ch;
while ((ch = getch()) != EOF)
{
if (ch != '\r')
putchar (ch);
} // while
Two more tools:
tr -d '\r' < dosfile > usablefileLastName,FirstName,Assignment,NumericGrade
find the the five highest grades on HW2
know HTML, those will typically look like <img ... src="*URL"...>
* The img can have any capitalization (img,
IMG, Img, iMg, etc.)
* There can be other text between the img and the
src. (That text cannot include a greater than sign.)
* You may find it easier to start this problem by assuming that there's
only one image tag on a line.
* But, in the end, you should support multiple image tags on the same line.
!! repeat the last command!text repeat the last command that starts with the given text!123 repeats command 123!$ the last thing on the last lineThis will appear online some time in the near future (probably over the weekend).
Repository: https://github.com/Grinnell-CSC282/hw1
Read chapter 1 of Raymond to get a deeper understanding of the *nix Philosophy.
Find good solutions to any of the tasks we did not solve in class. (That is, write a program or command to solve the task.) Put them in a folder with your name in the GitHub repository.
Make a list of *nix tools and utilities that you've found useful (or
even that you've just heard of). Try to categorize and add a short
description. Put them in the tools.md file in the repository.
Add some notes about what might be wrong with the C code above.
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [Teaching & Learning] - [Calendar]
Current: [Outline] [EBoard] [Reading] [Lab] [Assignment]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines]
Reference: [EBook] - [ISO] [GNU Coding Standards] [GCC Documentation] - [TAoUP] [Make3]
Related Courses: [CSC 295 2013S]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker]
Copyright (c) 2013 Samuel A. Rebelsky.

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this
license, visit http://creativecommons.org/licenses/by/3.0/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.