From the course: C Standard Library

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

String examination example

String examination example - C Tutorial

From the course: C Standard Library

Start my 1-month free trial

String examination example

- [Instructor] All right, so let's illustrate the string compare and strstr functions. In this application, I have written a main function in line seven that defines for strings. They say strings in some programming language are easy. And next I have a series of calls to a compare function that will compare pairs of those strings, and my compare function will print out which of the strings is greater than the other or less or if they are equal. That's why I made a function right there. So our first task in line four is to write that function. So our next task will be, as you can see in line 18, we have a substring definition. It's initialized as Java, and we will look for that substring within one of those strings. And so I'll write some code there so that you can see strstr working. Okay, so let's start with the compare function. I'll start writing codes in line five, and it's as easy as calling the STRN Compare function and analyzing its results. So let me define an integer called…

Contents