Hello, and welcome back. Here we have another challenge. So I hope you guys are getting
familiar with strings, character arrays. A very important concept with c.
This idea of storing these string literals in variables, character arrays,
understand that it's an array and how you can access different elements.
This challenge is going to be focused on that.
We're going to have another challenge that helps you understand how to use some of the string functions
because we cover a lot of those.
But this one really is for you guys to get familiar with this concept of a character string
and a character array.
So the requirements for this assignment
are you're going to write a program that tests your understanding of character arrays.
So what I want you to do is I want you to write a number of functions.
I want you to first write a function that counts the number of characters in a string.
It would be similar to the stir length, but you're going to actually implement it yourself
without using that function.
So you cannot use the sterling library function.
The function should take a character a as a parameter,
and it should return an int.
So you can just have a character array as the parameter.
You don't have to worry about pointers at all in this assignment.
This is just going to take maybe a parameter constant because it's not going to change.
And all you're going to do is you're going to need to iterate through the array.
So even though you have a string,
you're still can access individual characters because it's an array.
So if you can access the individual characters, you can just keep a count and then display it.
This function should return an integer, which is the length.
The next function i want you to write is I want you to implement the concatenate
function where you can concatenate two strings.
Again, I don't want you using any library functions, don't use str cat.
This function should take three parameters,
the result and then the two characters
that you want to concatenate, the two strings that you want to concatenate.
So those can be constants because you're not going to change those.
The result is just going to be the character string that you store in.
So pretty simple. Again, you don't have to deal with pointers.
You're going to have a couple loops, go through each one of the
arrays and assign to the result array.
And what you should return for this function is nothing.
You don't have to return anything because you're passing in the result array.
We could modify this and return a pointer and stuff like that but we're not going to do that for this assignment.
So this is going to manually concatenate two strings.
Third function I want you to write is to compare two strings to see if they're equal.
Again, I don't want you to use the library function, I want you to understand how these character arrays work.
This function should take two constant character arrays as parameters
and it should return a Boolean,
either true or false. True if they're equal, false otherwise.
So what are you going to have to do,
you're going to have to iterate through the arrays and compare each character.
And you should probably look for the null terminator
for the equal strings because the null terminators can determine when you want to stop.
Because you don't have the sizes of these arrays
so you're going to have to look for null terminator to determine when the second string.
And you should actually compare the second string to the first.
So you have to figure out how to do this. But here's three functions to get you familiar
with creating a character array
and manipulating it or accessing it to determine its length
concatenating it and checking if it's equal.
Good luck. I'll provide a solution in the next lecture. Thank you.