• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
string help required.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

string help required.


  • Subject: string help required.
  • From: "D. Walsh" <email@hidden>
  • Date: Tue, 6 Sep 2005 13:12:38 -0400
  • Mta-interface: amavisd-new-2.3.3 (20050822) at daleenterprise.com

While this may be basic for most, I can't seem to make it work and it's probably because I don't know enough.

I'm trying to search a line buffer for a string and as long as the string appears at the start of the line buffer it matches but anywhere else in the line it doesn't match.

Can someone help me with this search pattern so that it locates the pattern regardless of position in the line buffer?

Here's what I have for code:


    sprintf((char *)patternToSearch,"%s", (char *)my_search_string);

    while (fgets(buffer, sizeof(buffer), fp)) {
    sprintf((char *)patternToSearch,"%s", (char *)my_search_string);
        if (strncmp((char *)patternToSearch, buffer, strlen((char *)patternToSearch))) {
            /* are we writing to a temp file? */
            if (file_cmd == 4) {
                fputs(buffer, temp);
            }
        } else {
            matched = true;
            /* are we writing to a temp file? if yes then comment out the matched line */
            if (file_cmd == 4) {
                fprintf(temp, "#");
                fputs(buffer, temp);
            }
        }
    }
    if (is_verbose) {
        if (matched) {
            printf("Found match for : %s\n", patternToSearch);
        } else {
            printf("No match for : %s\n", patternToSearch);
        }
    }

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: string help required.
      • From: Phil Brayshaw <email@hidden>
  • Prev by Date: setting build subtasks in build configurations?
  • Next by Date: Re: Undefined STL symbols in xcode...
  • Previous by thread: Re: setting build subtasks in build configurations?
  • Next by thread: Re: string help required.
  • Index(es):
    • Date
    • Thread