STRSTR features in the Linux kernel

Source: Internet
Author: User

See the STRSTR function in the kernel code:

mode = STRSTR (Boot_command_line, "D:");

It should be a string handler, using the Man command to see the following explanation:

Synopsis       #include <string.h>       char *strstr (const char *haystack, const char *needle);       #define _gnu_source       #include <string.h>       char *strcasestr (const char *haystack, const char *needle);D Escription the       strstr () function finds the first occurrence of the substring needle in the       string haystack.  The terminating ' characters is not compared.       The Strcasestr () function is like strstr (), but ignores the case of  both       arguments.  Return VALUE       These functions return a pointer to the beginning of the substring, or NULL       if the substring are not Found.


Finds the first occurrence of the string needle in haystack, returns the seat pointer successfully, and finds no return null.
A simple example:

#include <string.h> #include <stdio.h>int main () {    char *haystack = "Hello, this was Csdn blog, I am Here"; 
   char *needle = "he";    char *temp;    temp = strstr (haystack, needle);    if (temp! = NULL)    {        printf ("%s\n", temp);    }    else    {        printf ("Can not find [%s] from [%s]\n", Needle, haystack);    }    return 0;}


$ gcc strstr.c-o strstr$./strstr

STRSTR features in the Linux kernel

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.