GithubHelp home page GithubHelp logo

c-pointer-exercises's Introduction

C Pointer Exercises

In-class C pointer exercises. If not finished, will be due as homework.

Arrays

Static arrays

Global array

  1. Define a structure.
  2. Declare a static array of structures, outside of any function. What is the type of the array variable?
  3. Sketch the array on the worksheet.
  4. Assign values in a loop.
  5. Step through the code with the debugger.

Local array

  1. Define a structure.
  2. Declare a static array of structures, inside a function. What is the type of the array variable?
  3. Sketch the array on the worksheet.
  4. Assign values in a loop.
  5. Step through the code with the debugger.
Sketch

Static array (global or local)

Dynamic arrays

Monolithic array

  1. Define a structure.
  2. Allocate a dynamic array of structures. What is the type of the array variable?
  3. Sketch the array on the worksheet.
  4. Assign values in a loop.
  5. Free all dynamic memory.
  6. Step through the code with the debugger.
Sketch

Dynamic monolithic array

Array of pointers

  1. Define a structure.
  2. Allocate a dynamic array of pointers to structures. What is the type of the array variable?
  3. Sketch the array on the worksheet.
  4. Assign values in a loop.
  5. Free all dynamic memory. Mind the order to avoid leaving dangling pointers!
  6. Step through the code with the debugger.
Sketch

Dynamic array of pointers

Linked lists

  1. Declare a node structure for a singly-linked list, holding a single int value.
  2. Declare the list's head and tail pointers.
  3. Initialize the linked list. What does an empty list look like?
  4. Reason out the different assignment cases for the list_insert function. The nodes have to be inserted in ascending order. How should the pointer member of the node structure be initialized by default?
  5. Implement the list_insert function, for all cases you came up with.
  6. Test the function for all the cases. Run in the debugger to see if it works. Correct it.
Sketch

Singly-linked list

c-pointer-exercises's People

Contributors

ivogeorg avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.