Identifying string input

This is a discussion on Identifying string input within the C Programming forums, part of the General Programming Boards category; Under the processinfo function, how can i identify that "are" existed in the *inputx ?? Code: main() { char xyz[20] ...

  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,796
    >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-26-2003, 11:03 PM
  5. Basic C Programming Help Needed
    By Smurphygirlnz in forum C Programming
    Replies: 8
    Last Post: 09-26-2002, 07:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21