ucfstudyunion.files.wordpress.com€¦  · web view// our temp will use it to get to every struct,...

35
Introduction to C Programming with Yoannier I’d like to give a warm welcome to all of you for either attending this session, watching my stream, or even for checking our this document far in the future! We will be going over material from the humble beginnings of the C Programming course. For starters, we will touch lightly on early concepts, such as variables and operations. The session will gradually climb to File I/O and Linked Lists. In any case… Thank you!

Upload: others

Post on 31-Aug-2019

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

Introduction to C Programming with Yoannier

I’d like to give a warm welcome to all of you for either attending this session, watching my stream, or even for checking our this document far in the future!

We will be going over material from the humble beginnings of the C Programming course. For starters, we will touch lightly on early concepts, such as

variables and operations. The session will gradually climb to File I/O and Linked Lists. In any case…

Thank you!

Let’s dive right in!

Page 2: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

Memory Lane

What are…? Variables: Things we can make (or declare) in programs by giving them names.

We can set (or initialize) them to values and use them in many ways.

Datatypes: The kind or “species” that a variable can be. Variables can only hold specific values of their datatype.

Functions: These are like drawing boards in our program. They do the work coded in them but may require their parameters to do it. They have return types, which decide what the function must return (if its return type is not void).

Parameters: Like variables, they have a name and a datatype. However, they are declared in a function’s within its parentheses, like so: void exampleFunc(int myParameter).

Arrays: Special variables that can hold multiple values of a chosen datatype. These values are ordered, starting from “index 0”.

String: An array of type char. printf() and scanf() recognize it with %s. Their last meaningful index should be set to the null sentinel, or ‘\0’.

While loop: A clever mechanism that allows segments of code to be executedover and over. As long as the condition specified within its parentheses is met, the code inside it will continue to be executed.

For loop: A mechanism similar to a while loop. The difference is that is has three statements between its parentheses: The first one initializes your variable, the second one is your condition like the while loop, and the third one is the statement executed every time the loop iterates.

If-else: If statements are special. They hold a condition like a loop does, and its code will be executed if the condition is met. An else statement will be entered instead if the if statement is NOT met. An else-if statement offers an alternative like an if does, but can’t be met at the same time as an if statement right above it.

Page 3: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

These are the fundamental but ever-present concepts we’ll be seeing, even for our final!The following page will attempt to test your memory of them! Let’s go!

Variables Which of the following variable declarations is incorrect?

a. int age;b. char Letter;c. Char letter;d. double cost;

DatatypesOut of the datatypes listed below, which of these is best for storing how many

days are left until Avengers: Endgame comes out?

a. charb. intc. doubled. float

Functions & ParametersThere are some errors below. How can we fix them?

int yourAgePlusTen(int yourAge){

int someVariable;printf(“Hiya, welcome to Study Union! Enter your age: “);scanf(“%d”, &age);printf(“You entered %d.\n”, &yourAge);

return yourAge + 10;}

int main(){

int yourAge, int newAge;

newAge = getInfo();someVariable = 5;

printf(“Your age plus 10 is %d.\n”, newAge);

Page 4: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

return 0;}

ArraysWhat’s wrong with the following code below? Why is it incorrect?

int main(){

int data[10];

data[0] = 0;data[10] = 100;

return 0;}

Strings and String FunctionsDo we know what this code will print out? If so, what will it print out?

int main(){

char name[100];

strcpy(name, “Donald”); // Strcpy means String Copy.

printf(“My name is %s.\n”, name);

strcat(name, “ Duck”); // Strcat means String Concatenate.

printf(“My full name is %s.\n”, name);

if (strcmp(name, “Donald Trump” == 0) // Strcmp means String Compare.{

printf(“Donald Duck is Donald Trump!?\n”);}

return 0;}

Page 5: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

While LoopsWhy is this incorrect? What is missing?

int main(){

int i = 0;

while (i < 10){

printf(“i is %d.\n”, i);}

return 0;}

For LoopsCan we guarantee that these two are correct? If not, what is wrong?

int main(){

int i;

for (i = 0; i < 10; i++){

break;printf(“Intro to C is super awesome.\n”);

}

return 0;}

int main(){

int i;

for (i = 10; i <= 0; i--){

continue;printf(“Intro to C is super awesome.\n”);

}

Page 6: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

return 0;}

If-ElseWhich of the following if-else statements will execute?

int main(){

int num = 5;

if (num == 5){

printf(“Num is 5.\n”);}

else if (num > 0){

printf(“Num is greater than 0, this HAS to execute!\n”);}

if (num < 0){

printf(“Num is apparently less than zero.\n”);}

else{

printf(“Num must’ve not been less than zero!\n”);}

return 0;}

Hooray! We’ve made it this far already! Some questions might have been tricky for you, but that’s the extent of how tricky those concepts can get for us!

You might’ve noticed we haven’t gone over the tougher aspects of C Programming… That’s because they each have their own pages to themselves!

Let’s jump to the next stage!

Page 7: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

STRUCTSHuh? What’s a struct!?

These are real nice tools a programmer can use in C. They’re like a special datatype you create that holds a bunch of related information all together. This information is a set of variables within your struct, called “member variables”.

You’ll have to declare a variable of this new “datatype” you’ve made in order to access its member variables. Variables of any datatype can be a member!

I must emphasize: you create the blueprint for one of these above any of your functions!

Give me some examples!struct ContactInfo{

char name[100];int age;char address[100];

}; // Notice these semicolons. You MUST end your blueprint with them!

struct Student{

int UCFID;float GPA;char favoriteCourse[100]; // COP3223, obviously!

};

Page 8: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

How Do We Use ‘Em?As we see here, the member variables are within the curly braces of these

struct blueprints. Let’s see how it looks when we declare some variables of these structs!To declare a variable of a specific struct, you must first write struct, then

write your struct’s name, THEN you can write your variable’s name. The “struct ContactInfo”, for example, is like the datatype of the variable.

To access a specific member of your variable, you write the variable name, followed by a dot ( . ), then write the name of the member!

Let’s assume we’re using the structs we declared earlier.

int main(){

int i;struct ContactInfo myInfo;struct Student student1;

student1.UCFID = 1234567;student1.GPA = 4.0;

strcpy(myInfo.name, “Thanos”);

printf(“Hello. I am %s and I am a UCF student.\n”, myInfo.name);

return 0;}

Page 9: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

Alright, How About Some Problems!?What’s wrong with our code here? There’s more than one error!

struct ExampleStruct{

int value;char ch;

};

int main(){

ExampleStruct example;

value = 0;ch = ‘c’;

return 0;}

How about this one? Spot the errors!

PoliceOfficer{

char name[100];int yearsInDuty;char favoriteDonut[100];

}

int main(){

struct PoliceOfficer cop;

cop.name = “Doug”; // Hint: There’s a correct way to do this!cop.yearsInDuty = 20;cop.favoriteDonut = “Strawberry Frosted”;

Page 10: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

return 0;}

This one’s a little tough. It gets its own page! Yay!Only one error to look for!

struct miniStruct{

int num;float decimal;

};

struct VeryBigStruct{

char letter;struct miniStruct mini;

};

int main(){

struct miniStruct tiny;struct VeryBigStruct bigBoi;

bigBoi.letter = ‘b;tiny.decimal = 3.14;

bigBoi.letter.decimal = tiny.decimal;

tiny.letter = ‘t’;

return 0;}

Let’s reflect for a minute:

We can make variables of a struct “datatype”, right?

Page 11: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

But can variables of any datatype be a member variable?

POINTERSMhmm, the Infamous Pointer, I See!

Indeed, these fellows are pretty strange at times!To understand them, we must first understand this:

When we declare variables, they each occupy room in our memory space. Think of memory space like a bedroom. You only have as much space as your room allows. When you buy a vase and place it in your room, you’ve, metaphorically, made a new variable that takes up space in your “room”. Each item in your room has a specific spot where you can find them, which is also known as an “address” for where variables take up space in memory.

Pointers are very special. We can declare them just like regular variables, and they’ll also be set to “garbage” by default, like other declared variables too. They’ll also need to be initialized. What can they be initialized to, you ask?

The locations of the “items” in your “room”! In other words, the addresses of variables you’ve declared! However, depending on the pointer variables you’ve declared, they can only point to certain things. You decide which datatype they can point to, then type the * symbol, then write the name of your pointer variable!

Now we have a secret back-door that lets us change the value of a variable when we have its address. Now that we know its “actual location”, we can change that other variable’s value using the pointer! It even works outside of the main() function!

Page 12: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

When accessing the value found at the address the pointer holds, we write *<name_of_pointer> to dereference the pointer, or GO TO the address that it holds.If it’s uninitialized, or garbage, then it’s dangerous! We don’t know what address an unintialized pointer holds!

This technique is what makes pointers pass-by-reference, unlike non-pointer variables, which are pass-by-value. Good to note: Arrays are ALSO pass-by-reference!Let’s see some examples!

int main(){

int i;int *ptr; // Pointers are written like so: <datatype> *<name>;

ptr = &i; // This & represents the address of the variable i.// Notice how ptr is a pointer to an integer, and i is an integer!

*ptr = 10; // Go to the location where the variable i is found in memory, and change // the value of it there!

printf(“Look! The value of i is now %d!\n”, i);

printf(“The address of i is %p.\n”, ptr); // We use %p to print out addresses.// They usually look something like: 0xfc01ab.

return 0;}

Here is the Swap Function, which lets us swap values from different functions:

void swap(int *a, int *b){

int temp;

temp = *a;*a = *b; // When we go to the address in our pointer, we change its value for good.

// Luckily, we kept track of its value in our temp!*b = temp; // Now the value at the address in b is holding what *a was.

}

Page 13: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

int main(){

int val1 = 3, val2 = 5;

swap(&val1, &val2);

printf(“Now a is %d and b is %d!\n”, val1, val2);

return 0;}

Notice that we had passed the addresses of val1 and val2. Now, we can even affect their values in different functions. However, we’ll need pointers to ints to be able to do that!

Problems, Please!Is there anything wrong with the following code below?

int main(){

int i, *pi;

*pi = &i; // Think: what is the * doing to the pointer here?

return 0;}

What should the output of this code be?

void changeArray(int data []){

int i;

for (i = 0; i < 5; i++){

data[i] = 100;}

}

int main(){

int i;int data[5];

Page 14: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

for (i = 0; i < 5; i++){

data[i] = 0;}

changeArray(data);

for (i = 0; i < 5; i++){

printf(“data[%d] is %d.\n”, i, data[i]);}

return 0;}

Remember that arrays, like pointers, are pass-by-reference!

What’s Dynamic Memory Allocation?It’s an important way of being able to give an address for pointers to point to without having to declare a variable to do it!So instead of:

ptr = &i;

We can call a function called malloc (finds memory in the memory space you can use, which returns a location or address to this memory) or calloc (does the same as malloc, but useful for struct pointers. It sets the member variables in that memory to default values).

We can use malloc to give ptr its own memory to play with instead of our variable i’s memory:

ptr = malloc(sizeof(int));

We use sizeof(???) in the malloc to give some memory for ptr to play with. We replace the ??? with the datatype the pointer can point to. This also works for arrays, since they’re pass-by-reference!

char *name = malloc(sizeof(char) * 100); // Arrays are pointers, so we can declare them // like this!

or

char *name = calloc(sizeof(char), 100); // First parameter: space per index, second: // how many of that size we need (or indices

total).

Page 15: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

This means our string called name has 100 indices we can use!

What Was That About Struct Pointers???Just like with regular pointers, they can only point to a specific

“datatype” or specific struct that is mentioned when declaring a struct pointer.The only difference now is:

You don’t use the ( . ) anymore! Struct pointers use (->) instead! It’s essentially an arrow.

Let’s see some problems with them:

What can we expect the output to be here?

struct Student{

int UCFID;int GPA;char zip[100];

};

void setStudentInfo(struct Student *studPtr){

studPtr->UCFID = 1111111;studPtr->GPA = 0.0;studPtr->zip = 32816;

}

int main(){

struct Student student1;

setStudentInf(&student1);

student1.UCFID = 123456;

printf(“student1’s UCFID is %d.\n”, student1.UCFID);

return 0;}

Page 16: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

Let’s check out this one, which uses malloc instead. What stuff is wrong here?

struct VeryBasic{

char letter;}

int main(){

struct VeryBasic test = malloc(sizeof(struct VeryBasic));

test.letter = ‘j’;

return 0;}

FILE I/OThis nifty little tool in C allows us to perform operations with text files.

Like What?We can find a specific file of our choosing by using a file pointer.

From there, we can decide if we want to read, write, or append to the file.

File Modes:Read: Denoted with “r”. It means to read information from a file. We may run into an error if the file does not exist.

Write: Denoted with “w”. It means to clear an entire file and start writing information into it. If the file does not exist, the computer will make it for you.

Append: Denoted with “a”. It means to go to the end of a file and start putting information there. If the file does not exist, the computer will make it for you.

This is how it works:

int main(){

char buffer[1024]; // We choose a big size for our string to hold lots of stuff.FILE *fp = fopen(“helloworld.txt”, “r”);

Page 17: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

// fp is our file pointer. It’ll tell our code where the file is located. // We use fopen to open the file. Its first parameter is your file// (which may require your text file to be in a specific folder),// while the second parameter is the file mode you choose.

if (fp == NULL) // NULL means nothing. We must’ve not found the file!{

printf(“Oh no! We didn’t find the file you seek!\n”);exit(0); // Exit the program entirely, not just the function.

}while (!feof(fp))// While we haven’t reached the end of our file, keep looping!// You must pass the file pointer to feof().{

fgets(buffer, 1024, fp);// fgets reads an entire line at a time in our file. // Its first parameter wants a string to store the file content into,// its second parameter asks how many characters you’d like to read // on the line we’ll read, and// the third parameter asks which file we’re talking about!

printf(“Buffer is %s right now.\n”, buffer);}

return 0;}

What About Writing?Very similar! fgets() is good for reading from a file and putting the line of info into a string, so we have an exact opposite!

fputs(). This function puts a provided string into our file. Here’s an example:

int main(){

int i;char buffer[100];FILE *fp = fopen(“Earth_is_flat.txt”, “w”); // We’ll wanna change this file!

strcpy(buffer, “Not true! Earth is ROUND!!!\n”);

for (i = 0; i < 10; i++){

Page 18: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

fputs(buffer, fp); // Only TWO parameters here! The string and the file // pointer!

}

return 0;}

What can we say our Earth_is_flat.txt is full of? How many of this should we expect to see?

Hey, What About Append?The awesome part is that it’s virtually identical to write. The only difference is a file having additional stuff written at the end of it! You won’t see append often, but do recall what the “a” stands for!

LINKED LISTSThis is it. This is the “big cheese” of this packet. I hope you’re ready!

“Big Cheese?”Linked Lists are hard to wrap one’s head around at the outset. Essentially, they’re structs with an added twist. It’s easiest to explain with an example.

struct ContactInfo{

char name[100];char address[100];int age, weight;struct ContactInfo *node; // The Linked List trait.

};

Whooooa, what? Yes, one of the member variables of the struct is actually a pointer!Not just any pointer, either. It’s a pointer to the same datatype as the struct!

Page 19: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

Let’s break it down. If we declare a variable of this struct, it has its own name, address, age, weight, and a node. For structs like these, we prefer to declare a pointer of this kind of struct. We expect to see this specifically:

struct ContactInfo *ci;

However, as we know, this pointer is uninitialized! It needs an address to play with! Dynamic Memory Allocation to the rescue!

ci = calloc(sizeof(struct ContactInfo), 1); // Only want one struct to play with.

Let’s go ahead and set values to this variable’s members.

strcpy(ci->name, “Quasimodo”); // Er… Quasi Moto?strcpy(ci->address, “123 Main St);ci->age = 40;ci->weight = 170;

However, here’s the doozy:

How do we set ci’s node member?Well, ci->node is, itself, a struct ContactInfo *. We can also calloc it!

Once we give it a location to point to, this means we’ve made yet another block of memory dedicated to a struct! We have now linked two structs together!

ci->node = calloc(sizeof(struct ContactInfo), 1);

Now that ci->node has an address to play with, we can set ITS members to things, too! Follow closely.

ci->node->age = 20;

(ci->node) is the struct variable in question. We’re going to set its age to 20. Cool?

strcpy(ci->node->age, “Douglas);strcpy(ci->node->address, “321 Not-Main St);ci->node->weight = 121;

Remember how we stated that ci->node was a struct ContactInfo *?This means it has a node member! The node can be given memory via calloc, too!

Page 20: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

ci->node->node = calloc(sizeof(struct ContactInfo), 1);

Whoa, Buddy! Calm Down!I totally understand. It’s rather tough to wrap our heads around this business. A great way to represent this is with a visual diagram.

Notice how ci is pointing to the box that has “Rick” in it.This was our very first struct variable that we’ve made! This makes ci the “head” of our linked list.The address above the box was created by calloc so that we can actually play with a struct.

Remember how we gave ci->node an address with calloc too?It’s pointing to the box that contains “Douglas” in it.

We also gave ci->node->node an address, but didn’t input anything special into it.After using calloc, ci->node->node has a node member who points to NULL, or nowhere. This means that ci->node->node is the “tail” of our linked list; it’s the last struct we have in our chain of structs.

Jeez, We’re Writing Node Too Much!It’s true! There’s an important variable we always use when using linked lists. We always have one variable represent the head of our list and have another variable be the one who navigates through our list of structs, one-by-one. This variable is our temp struct.

Let’s assume we’re working with the same linked list above, and that ci->node->node has meaningful information in it. Temp to the rescue!

Page 21: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

struct ContactInfo *temp = ci;

Our temp is now pointing to the same address that ci is pointing to.Notice the arrow highlighted in blue. This is where ci->node is pointing to.Since ci and temp are pointing to the same struct, this means that they both share the same node member! According to the picture, ci->node and temp->node are the same.

Check out what happens if we decide to make temp point to the same address as its own node member (point to the same address as temp->node):

temp = temp->node;

Page 22: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

Now, temp points to the second struct in our list. We’ve navigated from the first struct to the second one. If you’ve noticed the arrow highlighted in blue, this is the node member of the struct that temp now points to. We can use it to get to the third struct! All we simply need to do is:

temp = temp->node;This works because of where temp now points to. Don’t blink!

Page 23: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

We’ve followed the blue arrow once more (which is where the nodes of the structs point to) and made it to the third struct in our linked list.

If we move one step forward again with temp = temp->node; , it’ll mean temp ends up at NULL, or nothing.We can successfully say we’ve “walked the linked list”.

To recap, we:Needed a “head” struct, which was ci in this case, and a temp, which would navigate through the list using the node members of each struct.

Let’s say we wanted to create a linked list based off of the contents of a file.Let’s also say this file stores names and looks like this:__________________| Yoan || Donald || Rivest || Leinecker || Quasimodo || Thanos |__________________

// This function expects a linked list to be passed as the parameter.// This parameter holds the first struct in our linked structs. // Our temp will use it to get to every struct, one-by-one.

Page 24: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

// Also, linked lists do not need to exclusively be of struct ContactInfo. They can // be any struct as long as one of its members is a pointer to its own “datatype”.

void walkLinkedList(struct ContactInfo *head){

struct ContactInfo *temp = head; // Start at the first struct in the list.

while (temp != NULL) // While we haven’t reached the end of the list…{

printf(“This struct’s name is %s.\n”, temp->name);

temp = temp->node; // Follow the trail to the next struct!}

}

struct ContactInfo *makeLinkedListFromFile(FILE *fp){

struct ContactInfo *head = NULL, *temp; // Start off your head as empty.// We have not read from the file yet, nothing should be in the list.

char buffer[100]; // Big enough to hold entire names.

while (!feof(fp)){ fgets(buffer, 100, fp); // Read up to 100 characters per line from the file

// and store it into our buffer.

if (head == NULL) {

head = calloc(sizeof(struct ContactInfo, 1)); // Made our first struct. temp = head; // Temp must start at the head to walk through it.}

else {

temp->node = calloc(sizeof(struct ContactInfo, 1));}

strcpy(temp->name, buffer); // Store name into struct that temp currently // points to.

temp = temp->node; // Follow our blue arrow trail to the next struct we // made!

}return head; // We never moved head from the very first struct!

}

Page 25: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

int main(){ struct ContactInfo *ci; // When it comes to linked lists, we always declare a

// pointer.

FILE *fp = fopen(“random_text_file.txt”, “r”); // We’ll read from our file to // make a linked list.

if (fp == NULL){ printf(“Oh no! File not found!\n”); exit(0);}

ci = makeLinkedListFromFile(fp);

walkLinkedList(ci);

return 0;}

There are plenty of variations to this, but this one should be succinct enough to grasp the process of combing one’s knowledge of linked lists, pointers, structs, and loops together all at once.

Page 26: ucfstudyunion.files.wordpress.com€¦  · Web view// Our temp will use it to get to every struct, one-by-one. // Also, linked lists do not need to exclusively be of struct ContactInfo

Any Bonus Content?

Any extraneous remaining content may include things like recursive functions and two-dimensional arrays.

For generic practice, I defer you to my UCF SI Wordpress site (easy search via Google) for these examples, along with a plethora of other examples. They can be found on my packets attached in my “Introduction to C Programming” page. It is possible that this content may have been covered during the Study Union stream, which can be found on Webcourses->Front Page->Study Union Announcement. Any questions?