Thread: Identifying string input

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    41

    Identifying string input

    Under the processinfo function, how can i identify that "are" existed in the *inputx ??

    Code:
    main()
    {
    char xyz[20] = "hellohowareyoudoingthere";
    
        processinfo(xyz);
    }
    
    void processinfo(char *inputx)
    {
    
    
    }

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >how can i identify that "are" existed in the *inputx ??
    Code:
    #include <string.h>
    
    if ( strstr ( inputx, "are" ) != NULL ) {
      /* "are" was found */
    }
    else {
      /* Not present */
    }
    >main()
    int main ( void )

    >char xyz[20] = "hellohowareyoudoingthere";
    This totally writes past the end of the array. Do this instead if you have trouble counting characters in a string literal:
    Code:
    char xyz[] = "hellohowareyoudoingthere";
    >processinfo(xyz);
    >}
    Squeeze a "return 0;" in between those two lines.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  2. Compile Error that i dont understand
    By bobthebullet990 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 09:19 AM
  3. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 03:58 PM
  4. lvp string...
    By Magma in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2003, 12:03 AM
  5. Basic C Programming Help Needed
    By Smurphygirlnz in forum C Programming
    Replies: 8
    Last Post: 09-26-2002, 07:12 PM