string search

This is a discussion on string search within the C++ Programming forums, part of the General Programming Boards category; i am trying to make an inventory programme. what i need to know is how to search strings in a ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    142

    string search

    i am trying to make an inventory programme. what i need to know
    is how to search strings in a file so i can store information then retreive it later, if anyone knows how to do this that would be appreciated,


    cheers
    WhAtHA hell Is GoInG ON

  2. #2
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Read the file into a buffer
    Lookup strstr()
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  3. #3
    ... arjunajay's Avatar
    Join Date
    May 2005
    Posts
    203
    This one was given by prelude
    Code:
    const char *sub(const char *m, const char *s){
    do {
    	const char *p, *q;
    
    	for (p = s, q = m; *p == *q; p++, q++)
    	  if (*(q+1) == '\0')  return s;
    } while (*s++ != '\0');
    
      return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 03:45 PM
  2. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 03:40 AM
  3. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  4. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 11:06 PM

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