Main Menu

HOME

.Net
ASP
Assembly
C
C++
Delphi
HTML
Java
JavaScript Site
MySQL
PC interface
Powershell
Perl
PHP
VBScript
Visual Basic
XML

US Job listings




   Misc

   Amazon

   Links

    


String in another
 

 

 

Description

This example uses the strstr function to see if a string appears in another string

Code

/**************************************
this example uses the strstr function to
check if str2 appears in str1
***************************************/
#include <stdio.h>
#include <string.h>

int main(void)
{
char *str1 = "programmershelp.co.uk c section";
char *str2 = "section";
char *substring;
/*check to see if str2 is in str1*/
substring = strstr(str1,str2);
if (substring != NULL)
printf("%s\n",substring);

return 0;
}

Information

tested using Visual C++ 6

 

 

 

 

 

Download

strstr.txt


 




   Sponsors
 

   Software
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals

   Source Code
Screen size(Javascript)
View source code(VB)
Open a file and display contents(C++)
delete files on a floppy disk(VB)
Image display(ASP.net)
list files of a certain type in a word document(VBScript)
save text to a file(VB)
Download an RSS feed(Powershell)

    




Copyright © 2003 by programmershelp.co.uk