User Profile

Collapse

Profile Sidebar

Collapse
radostin
radostin
Last Activity: Feb 12 '11, 07:03 PM
Joined: Feb 8 '11
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • radostin
    replied to How to find a string in another string?
    in C
    Bassically I am asking if shotString is in longString and then I want to know how many times. The part I am having difficulty with is this.
    Code:
     ptr = longString;
      
     while(ptr!=0){
           ptr = strstr(ptr,shortString)
           i++;}
    I am not a hundered percent on how to count how many instances shortString is after i've found out that it is present in longString.
    See more | Go to post

    Leave a comment:


  • radostin
    started a topic How to find a string in another string?
    in C

    How to find a string in another string?

    I'm sure you've seen this a million times but, I'm having some trouble with my code.


    Code:
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    
    
    main (void){
    
    char* longString = " This is where a string with some shit goes; where else would it go?";
    char* shortString = " where";
    char* ptr;
    int i = 0;
    ...
    See more | Go to post
No activity results to display
Show More
Working...