Advanced C Programming

Fall 2022 ECE 264 :: Purdue University :: Section 3 (Quinn)

⚠ This is a PAST SEMESTER (Fall 2022).

Syllabus

Course information
ECE 26400 - Advanced C Programming - 3 credits
Section 3 - CRN 22821 - Tue/Thu 9:00-10:15am - WALC B058 (face-to-face)
Section 4 - CRN 30656 - Tue/Thu 9:00-10:15am - Boilercast (sync-online)

Prerequisite: CS 15900 with a minimum grade of C-

Course description “Continuation of a first programming course. Topics include files, structures, pointers, and the proper use of dynamic data structures” (official catalog description)
Instructor Alexander J. Quinn
MSEE 262 - 765-494-3483 - aq@purdue.edu
Office hours: Mon/Thu 11:15am-12:45pm by Zoom
Learning Resources, Technology & Texts

Textbook

Computer Science: A Structured Programming Approach Using C (3rd Edition) by Behrouz A. Forouzan (ISBN 9780534491321)

We will direct you to the appropriate sections of the book so that you can prepare for class and strengthen your understanding of concepts and practical issues. However, this course is about “Advanced C Programming” (a verb), not “The C Language” (a noun). As such, the foundation of your learning will come from practice. If you are good at finding resources online, you may be able to get through the course without purchasing the textbook, depending on your learning style. No assignments will directly depend your having access to the textbook.

Software/web resources

You will access course resources through a computer cluster known as ecegrid. To access ecegrid, you will use PuTTY (Windows) or Terminal (Mac or Linux).

Most information will be available through the course web site:
https://engineering.purdue.edu/ece264/22au/

Hardware requirements

You can access the course resources using any computer.

Tutoring support

TAs will be available for one-to-one assistance learning concepts necessary to complete homework and assessing code quality. TAs will not assist in ways that deprive students of the opportunity to learn problem-solving skills. In other words, they will not debug your code or guide you to a solution to a homework.

Brightspace learning management system

We will not use Brightspace, except as a path to access recorded lecture videos (Boilercast).

Topics Lectures and assignments cover the following topics:
  1. Editing code using Vim
  2. Data representations: number bases, ASCII, strings
  3. Strings: basic operations (with and without string.h), null terminator
  4. Debugging with GDB
  5. Test-driven development
  6. Unit testing
  7. Preprocessor: #define ▒▒▒(…) macros, #ifdef, __FILE__, __LINE__, gcc -D▒▒▒
  8. Data structure: Linked list
  9. Data structure: Binary search tree
  10. Heap memory: malloc(…), free(…)
  11. Memory faults: leaks, overflows, overreads, conditional jump
  12. Memory fault diagnosis with Valgrind
  13. Memory model: stack, heap, data segment, text segment
  14. Sorting: tree sort and qsort(…)
  15. ANSI codes for color terminal-based interfaces
  16. String parsing: printf format codes, JSON
  17. Build automation: writing a Makefile from scratch
  18. Code quality
  19. JSON: parsing and generating
  20. Huffman coding: encoding
  21. Stack analysis: disassemble code and analyze memory dump including registers ($rbp, $rsp)
  22. Security: buffer overflow attack (create attack string to overwrite return address in vulnerable code)
Learning outcomes

Learning objectives

This course is designed to ensure that every student who passes will have mastered the following learning objectives:
  1. an ability to read and write C programs that use recursion
  2. an ability to read and write C programs that use structures
  3. an ability to read and write C programs that use dynamic data structures
  4. an ability to read and write C programs that use files

These learning objectives form the backbone for the content in this course. However, they do not pose an additional requirement for passing. Grades are determined solely by the formula in the section below.

Assignments

Your achievement of course learning outcomes will be assessed by way of homework (90%), quizzes (10%), and participation. Homework deadlines will be listed on the course web site. Quiz dates will be announced in class.

There will be no exams in this section.

Grades Grades for this semester will be calculated based on the following components:
90% Homework − weighted average
10% Quizzes

As a starting point, homework difficulty is presumed to be proportional to the number of calendar days you had to do the assignment, excluding official university holidays. Weights may be adjusted if it would improve fairness and/or help the class, at the instructor's discretion. For example, if a deadline is moved for reasons unrelated to the difficulty (e.g., holidays, etc.), the weight would be based on the deadlines.

Your letter grade is then found according to the following correspondence: S ≥ 85 ⇒ A,   S ≥ 82 ⇒ A–,   S ≥ 78 ⇒ B+,   S ≥ 75 ⇒ B,   S ≥ 72 ⇒ B–,   S ≥ 68 ⇒ C+,   S ≥ 65 ⇒ C,   S ≥ 62 ⇒ C–,   S ≥ 58 ⇒ D+,   S ≥ 55 ⇒ D,   S ≥ 50 ⇒ D–,   S ≥ 0 ⇒ F. 

A+ will be assigned to those who meet the criteria for an A and meet any of the following criteria:

  • Outstanding participation in ways that benefit other students and that your instructor can observe.
  • Among top 2% of students in the course by overall performance.

We expect to convert at least 20% of the A grades to A+. If many demonstrate excellent participation, this may be increased to as much as 50% of the A's.

Quizzes will be given in class.

Contingency plan for quiz administration. Quizzes will be given on paper, as a starting point. If a significant number of students are unable to attend or feel that in-person attendance would be unsafe, we may consider online options.

Contingency plan for grade calculation, and number of quizzes. If issues arise which make administration of quizzes problemmatic reduce the number of quizzes, and/or increase the number of quizzes. For example, this could arise if COVID-19 makes in-person class attendance too risky and an acceptably secure method of giving quizzes cannot be found. As of the beginning of the semester, we consider the likelihood of such a change to be low. If this does arise, the class will be consulted and feedback solicited, to the extent possible. The final decision will be made by the instructor.

You may earn extra credit through exemplary participation and/or bonus options on some homework assignments (if any).
  • Bonus points can be earned through optional "bonus" options in certain assignments. Each participation point is worth 1% of extra credit. The number is not preset. Bonus points are capped at 10 bonus points per person.
  • Participation points can be earned by demonstrating exemplary engagement with the course. Each participation point is worth 1% extra credit. The default is 0. The maximum is 10, and is very rare (i.e., only for extreme engagement and dedication throughout the semester). Participation will be assessed by your instructor at the end of the semester, based on any of the following:
    • helping other students in online discussions
    • asking insightful questions in class or instructor office hours
    • being first to report significant issues in homework assignments via the homework bug bounty
    • contributing to the class in other tangible ways

Bonus and participation points are optional, and not part of the denominator when calculating your grade. It is possible to achieve an A+ without any bonus or participation points.

Attendance

Students are expected to be present for every meeting of the classes in which they are enrolled. Only the instructor can excuse a student from a course requirement or responsibility. When conflicts or absences can be anticipated, such as for many University sponsored activities and religious observations, the student should inform the instructor of the situation as far in advance as possible…For unanticipated or emergency absences when advance notification to an instructor is not possible, the student should contact the instructor as soon as possible by email, or by contacting the main office that offers the course. When the student is unable to make direct contact with the instructor and is unable to leave word with the instructor’s department because of circumstances beyond the student’s control, and in cases of bereavement, the student or the student’s representative should contact the Office of the Dean of Students.

Bring the course reference sheet with you to every class.

Email The course staff are here to help you become a great C programmer. We will provide help with general questions during lab hours, instructor office hours, and via the Piazza forum. Do not send general questions by email to the TAs or to the instructor. This is so students with similar questions can have the best chance at benefiting from your question and the answer. If we answer the same question repeatedly to different students, it takes time away from new, different questions, and also poses a risk that we might give slightly different answers and create confusion. General questions sent by email will either receive no reply or else a canned reply reminding you of this policy.

If you have questions of a personal nature that apply only to you, or require confidentiality, feel free to send email to the instructor, come to office hours, or schedule an appointment to speak at another time.

Always include “ECE 264” in the subject line, and send from your ▒▒▒@purdue.edu email address.

Homework

There will be approximately one programming assignment per week. To fetch the starter files (if any), you will run the command 264get hw05 (or likewise for the other assignments) from ecegrid.ecn.purdue.edu. To submit, you will type 264submit hw05 hw05.c (or likewise).

Late work. Deadlines are at 11:59:59 PM according to the clock on ecegrid.ecn.purdue.edu, unless otherwise announced. Due to the number of people taking the class, deadlines must be strictly enforced. Homework submitted up to 24 hours late will be subject to a penalty of 30% of the total possible points. 24-72 hours late will be subject to penalty of 50% of the total possible points. 72-120 hours late will be subject to a penalty of 70% of the total possible points.

Compiler warnings. Code that causes compiler warnings with compiled using gcc v8.3.0 (64-bit Linux) with the flags -g -std=c11 -Wall -Wshadow -Wvla -Werror -pedantic. on ecegrid will be subject to a penalty of 40% of the total possible points.

Memory errors. Code that contains memory problems reportable by Valgrind will be subject to a penalty of 40% of the total possible points.

Code quality. Code that violates the code quality guidelines may be penalized 2% of the possible points per rule violated (any number of times).

Automated testers. For some assignments, we may enable automated testing prior to submission, to give you some early warning if it seems that your own testing was inadequate. These do not take the place of your own testing, and will generally not show the full detail about what test failed. Also, they may not include every test that will be used to score submissions. We may add more later, if we discover flaws in some student submissions that were not covered by the tester. Your job is to meet the assignment specification.

Multiple submissions. Your score will be based on the maximum of the following:
  • Score of latest submission as of the deadline.
  • Score of latest submission as of 24 hours after the deadline, minus 30% of the points possible.
  • Score of latest submission as of 72 hours after the deadline, minus 50% of the points possible.
  • Score of latest submission as of 120 hours after the deadline, minus 70% of the points possible.
Exceptions may occasionally be announced by the instructor prior to the deadline, such as for assignments that are to be human-graded.

You are encouraged to submit as often as you wish, even if your solution is incomplete. Submitting an incomplete solution increases the chance of receiving some points, in case you run into trouble later on. Also, every submission is backed up, so that we can help you in case of a disaster.

Partial credit. Where practical, partial credit will be given for submissions that meet the base requirements (below), and pass some but not all of our tests.

Base requirements. The following requirements apply to all assignments (where applicable), and are in addition to the requirements given in the assignment description.

  1. All required files must be included in a single submission.
  2. All required files must be named exactly as specified in the assignment description.
  3. Code can be compiled (as is) on ecegrid with gcc v8.3.0 (64-bit Linux) and the following parameters: -g -std=c11 -Wall -Wshadow -Wvla -Werror -pedantic.
  4. Code can run on ecegrid well enough to be tested.
  5. Code finishes in a reasonable amount of time (e.g., 2.0 seconds for most assignments)
  6. Function signatures and data types match the specification in the assignment description
  7. Any main(…) function must return EXIT_SUCCESS.
  8. Code follows our policy on academic integrity.

Any submission not meeting any of these eight base requirements will receive zero credit.

Homework bug bounty

For new or revised homework assignments, there may be unintended issues (e.g., ambiguities, inconsistencies, typos, etc.). Therefore, we are asking for your help in identifying issues with new assignments early.

The first person to find an report a significant issue—i.e., ambiguity, inconsistency, impossibility, or typos that substantially obscures the meaning—in a homework assignment will receive 1 participation point. Exceptionally insightful discoveries might receive 2 points.

You must post a message to the Piazza forum with the hbb tag and EXACTLY this subject (called “Summary” on Piazza):

HBB-HW##: description

Example:

HBB-HW01: Line numbers seem to be off

⚠ Your message must have the hbb tag and the subject must begin with HBB-HW## (replacing ## with the two-digit number of the relevant homework). For example, an HBB submission for HW01 should have a subject that begins with HBB-HW01.

Homework bug bounty points will be counted at the end of the semester by searching for that subject prefix (“HBB-HW##:”) and/or the hbb tag.

If you get the point, you will see “HBB ✔”.  If not, I will explain why and remove the "HBB-HW▒▒" from the subject line.

The instructor reserves the right to determine what constitutes “significant”, “first”, and ”exceptionally insightful”, and to limit the number of points per person per assignment. In other words, please don't spam the board with philosophizing about the meaning of words or silly stuff, but if you find something that might confuse your classmates, call it out.

C language standard We are using the C11 ISO/IEC 9899:2011 version of the C language, as compiled by gcc v8.3.0 (64-bit Linux) with the flags -g -std=c11 -Wall -Wshadow -Wvla -Werror -pedantic.
Regrades Follow the instructions on your Scores page.
Changes This syllabus is subject to change. In particular, homework contents and deadlines—may be changed without notice up to 1 week in advance. Homework weights may be adjusted at any time, to reflect the relative difficulty of the assignments. The grading scale cutoffs might be adjusted at any time, but any change between the beginning and end of the semester will be in students' favor. Other changes to course policies may be made to ensure the integrity of the course, to ensure fairness to students, or as otherwise deemed necessary by the instructor.
Academic integrity

Motivation

The vast majority of students at Purdue do their work honestly and with integrity. The value of their grades and their ultimate degree is based on the expectation that earning a good grade always requires learning the material well, and demonstrating that in a way that can be measured (e.g., exams and assignments). Those who cheat are eroding that value, the reputation of Purdue, and ultimately the value of your diploma.

Cheating is unfair to those who do their work honestly, and even to the few who do not. It defeats the purpose of being a student at Purdue. It also defeats our dual purpose as instructors in this course: (1) to teach you advanced C programming, and (2) to ensure that a good grade in ECE 264 is a dependable indicator of true proficiency in advanced C programming. If students are able to cheat, we have failed at both of those goals. For all of these reasons, we have a very strict stance against cheating.

Definitions

For purposes of defining cheating for this course, the following definitions apply:

  • “Copying” means reproducing any kind of data (including code, text, etc.) by any means (including copy-paste, copying files, hand-typing, etc.) from one source to another.
  • “Trivial modifications” – include differences in whitespace, variable names, function order, constant values, or other changes that affect the appearance but not the function or intellectual content of the material.
  • “Attribution” means explicitly acknowledging the source of copied content with a comment in exactly this format: /* Credit: <author>, <description>, <url_or_location> */.
  • “Authorized sources” include:
    • code that you have written yourself
    • starter code for assignments retrieved using 264get
    • names of C standard library functions (e.g., printf(…)) and keywords (e.g., #include)
    • any other source explicitly allowed by your instructor (with attribution).
  • “Unauthorized sources” include any of the following (unless explicitly allowed):
    • code from Stackoverflow, GitHub, Wikipedia, or any other web site
    • code from the textbook or any other book
    • test cases given in assignment descriptions
    • snippets provided by the instrucor (unless marked “OK to copy/adapt”)
    • any other source that is not an authorized source
  • “Cheating” includes doing—or attempting to do—any of the following:
    • Copying any amount of code from another students' code, the web, a book, or any other unauthorized source, even with trivial modifications. You may use code from the course reference sheet or code that you wrote yourself.
    • Allowing another student to copy your code
    • Using unauthorized means to alter or affect grades, submission timestamps, or submission contents, or anything else that might affect grades.

Copying code and then modifying it to make it appear different is still copying. Modifying the copied code (e.g., changing constant values, variable names, whitespace, etc.) is merely an attempt to hide the evidence of your copying—adding deception on top of plagiarism.

You must write your code from scratch using your brain and the letter and symbol keys on your keyboard. There should be no Ctrl-V (or Cmd-V or right-click anything) or email attachments at any point in the process.

Be careful not to reveal your code to others inadvertently. It is your responsibility to log out when you leave, and guard any printed copies of your work. If we discover two assignment submissions that are identical or very similar, both may be penalized.

Do not share your code on Github or anywhere else, during—or even after—the semester.

Do not copy code written by the instructor—even snippets from lecture or example test cases—unless it is part of the starter code or explicitly labelled as “OK to copy/adapt” (or similar). This provides freedom to discuss closely related problems in lecture or in the online discussion without spoiling the assignment. It also reinforces the principle that “your code” really does mean “your code” (i.e., written by you).

Never send your code by email.

Gray areas

Discussing abstract ideas and high-level strategies about homework assignments using converation and diagrams (e.g., standing at a whiteboard) is allowed and encouraged.

You may help a friend find a bug in their code, if you can do so with them in person on their screen and without editing their code, suggesting specific edits, or causing/enabling any semblance of “copying” (looking and typing, sending code by email, etc.). The best way to stay safe is to help them debug only after you have finished 100%, but that is up to you.

Use your discretion to avoid defeating anyone's educational opportunity (i.e., spoiling their challenge). This should not involve code.

Learning from code on the web or other sources is allowed, as long as you do not copy it by any means (including looking and typing it). Again, learning abstract ideas is allowed, though you should use good judgment to ensure that you learn how to solve programming problems.

Very generic code snippets (e.g., #include <stdio.h>) and the names of library functions should not require any copying. You should know those from memory.

Penalties

Very minor instances (e.g., 1-3 lines of code from the web on a homework) will result in a score of zero for the affected assignment. All other instances will result in an "F" in the course, and a referral to the Office of Student Rights and Responsibilities.

Penalties are not the goal, but they are a necessary component of an incentive system to shape behavior. To reduce the need for penalties, we spend time talking about academic integrity in lecture and there are often reminders scattered in assignment descriptions.

The giver and the receiver are equally responsible. The offense is not one's inability to complete the assignment, but rather the erosion of ethical standards.

Penalties will be applied even on the first offense, regardless of how you were doing up to that point. If someone asks you to share your code, your response should be, “No.”

We actively search for evidence of plagiarism and other types of academic dishonesty using a variety of methods.

Penalties may be applied whenever we find evidence of academic dishonesty—even long after scores were posted.

If are unable to finish a homework, cheating will only make things worse. If you copy code—even just half of one assignment—you will fail this class.

There are no penalties for discussing ideas in words or drawing pictures together in a way that does not entail copying. (Use your discretion.)

How to report cheating

Please report any cheating you see or hear about, or requests to share your code. You may notify the instructor in person, by email, or anonymously (e.g., non-Purdue email address that does not identify you, note under door, etc.). In doing so, you will be improving the fairness for the entire class, while also teaching the individual(s) a valuable lesson.

Even if you do not wish to name an individual, we welcome any feedback you may have about how we can ensure fairness and integrity in this course.

Penalties are not the goal. This is about teaching ethical conduct and preserving the intellectual integrity of our academic environment here at Purdue, while preparing you for a career producing intellectual property for hire in a legal environment where any infringement can bring lawsuits and penalties for companies. Also, ethics is a mandatory part of the engineering curriculum, as required by ABET (Accreditation Board for Engineering and Technology).

To minimize the need for penalties, we spend time in lecture and scatter reminders in assignments. However, enforcement is a necessary component of this effort.

Retraction

You may retract your submission of any homework without penalty by sending email to the instructor with subject line “retract HW▒▒ [264]” any time before the submission deadline.

Late registration

Students who register late must do all of the same assignments. If you register after any assignment is due, or less than 2 days before the deadline, you may request an extension by providing proof of the late registration to the instructor. The extension is not automatic.

Grief Absence Purdue University recognizes that a time of bereavement is very difficult for a student. The University therefore provides the following rights to students facing the loss of a family member through the Grief Absence Policy for Students (GAPS). GAPS Policy: Students will be excused for funeral leave and given the opportunity to earn equivalent credit and to demonstrate evidence of meeting the learning outcomes for misses assignments or assessments in the event of the death of a member of the student’s family.
Violent behavior Purdue University is committed to providing a safe and secure campus environment for members of the university community. Purdue strives to create an educational environment for students and a work environment for employees that promote educational and career goals. Violent Behavior impedes such goals. Therefore, Violent Behavior is prohibited in or on any University Facility or while participating in any university activity.
Disabilities

Purdue University is required to respond to the needs of the students with disabilities as outlined in both the Rehabilitation Act of 1973 and the Americans with Disabilities Act of 1990 through the provision of auxiliary aids and services that allow a student with a disability to fully access and participate in the programs, services, and activities at Purdue University.

If you have a disability that requires special academic accommodation, please make an appointment to speak with me during the first week of the semester in order to discuss any adjustments. It is important that we talk about this at the beginning of the semester. It is the student's responsibility to notify the Disability Resource Center of an impairment/condition that may require accommodations and/or classroom modifications.

Emergencies In the event of a major campus emergency, course requirements, deadlines and grading percentages are subject to changes that may be necessitated by a revised semester calendar or other circumstances beyond the instructor’s control. Relevant changes to this course will be posted onto the course website and/or sent by email to the Purdue email address (___@purdue.edu) of students registered in this course. You are expected to read your Purdue email on a frequent basis.
Nondiscrimination

Purdue University is committed to maintaining a community which recognizes and values the inherent worth and dignity of every person; fosters tolerance, sensitivity, understanding, and mutual respect among its members; and encourages each individual to strive to reach his or her own potential. In pursuit of its goal of academic excellence, the University seeks to develop and nurture diversity. The University believes that diversity among its many members strengthens the institution, stimulates creativity, promotes the exchange of ideas, and enriches campus life.

Purdue University prohibits discrimination against any member of the University community on the basis of race, religion, color, sex, age, national origin or ancestry, genetic information, marital status, parental status, sexual orientation, gender identity and expression, disability, or status as a veteran. The University will conduct its programs, services and activities consistent with applicable federal, state and local laws, regulations and orders and in conformance with the procedures and limitations as set forth in Executive Memorandum No. D-1, which provides specific contractual rights and remedies. Any student who believes they have been discriminated against may visit www.purdue.edu/report-hate to submit a complaint to the Office of Institutional Equity. Information may be reported anonymously.

Copyright

Among the materials that may be protected by copyright law are the lectures, reference sheet, this web site, assignments, and other material presented in class or as part of the course. Always assume the materials presented by an instructor are protected by copyright unless the instructor has stated otherwise. Students enrolled in, and authorized visitors to, Purdue University courses are permitted to take notes, which they may use for individual/group study or for other non-commercial purposes reasonably arising from enrollment in the course during the semester in which the student was enrolled.

Notes taken in class are, however, generally considered to be “derivative works” of the instructor’s presentations and materials, and they are thus subject to the instructor’s copyright in such presentations and materials. No individual is permitted to sell or otherwise barter notes, either to other students or to any commercial concern, for a course without the express written permission of the course instructor. To obtain permission to sell or barter notes, the individual wishing to sell or barter the notes must be registered in the course or must be an approved visitor to the class. Course instructors may choose to grant or not grant such permission at their own discretion, and may require a review of the notes prior to their being sold or bartered. If they do grant such permission, they may revoke it at any time, if they so choose.

// Credit: A substantial portion of this policy document is derived from a template authored by the Purdue Center for Instructional Excellence.