Search
 
SCRIPT & CODE EXAMPLE
 

C

strstr

if(strstr(sent, word) != NULL) {
    /* ... */
}
Comment

strstr

#include <iostream>
#include <cstring>
using namespace std;
  
int main()
{
    char s1[10] = "Hello";
  
    // return length of s1
    cout << strlen(s1) << endl;
  
    char s2[50];
  
    // copies s1 into s2
    strcpy(s2, s1);
    cout << s2 << endl;
  
    char s3[10] = "World";
  
    // concatenates s3 into s2
    strcat(s2, s3);
    cout << s2 << endl;
  
    char s4[50] = "HelloWorld";
  
    // return 0 if s2 and s4 are equal.
    if (strcmp(s2, s4) == 0)
        cout << "true" << endl;
    else
        cout << "false" << endl;
  
    char s5[30];
  
    // copies first 5 chars of s2 into s1
    strncpy(s5, s4, 5);
    cout << s5 << endl;
  
    char target[10] = "Hello";
  
    // search for target string in s4
    if (strstr(s4, target) != NULL)
        cout << "true" << endl;
    else
        cout << "false" << endl;
  
    return 0;
}
Comment

strstr

5
Hello
HelloWorld
true
Hello
true
Comment

PREVIOUS NEXT
Code Example
C :: command args c 
C :: insert image material ui 
C :: binary sorting 
C :: print 0 1 2 3 4 in c while loop 
C :: compile multiple c files 
C :: integer in c 
C :: round c 
C :: compile in c 
C :: logical operators 
C :: size of float in c 
C :: linear and binary search 
C :: ecto where is not nil 
C :: C/AL Convertion of Decimal to String/Text 
C :: fifo page algorithm in C 
C :: ouverture du fichier c 
C :: print in c 11111 00000 11111 00000 11111 
C :: create a gtk window 
C :: Battlefield4u.com 
C :: Computers round off numbers 
C :: int main() { int sum =0; FILE * ptr; ptr = fopen("d:students. "," "); if (ptr ==NULL){ ("file does not exist!!"); exit(0); } 
C :: python project script run 
C :: suma de digitos 
C :: c program for airthmetic operators 
C :: C program determines the height status for heights in cm 
C :: how to devowel string in c program 
C :: putting character in the begginig and end of sring C 
C :: QDrag and Drop 
C :: float 
C :: C printf Declaration 
Dart :: how to diable flutter for web 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =