Results 1 to 6 of 6

Thread: simple: How do search a dot in a string

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    simple: How do search a dot in a string

    How do know if there is one or more "." in a string.

    If there is any "." then I perform certain action, and If there is non then I do something else
    Baaaaaaaaah

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    for (char*i=string;*i;++i)
      if (*i='i')
          ;//cetain action
      else
          ;//something else
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Thanks man!
    Baaaaaaaaah

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Originally posted by kedaman
    Code:
    for (char*i=string;*i;++i)
      if (*i='i')
          ;//cetain action
      else
          ;//something else
    *cough*
    Code:
    if(*i == 'i')
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    ooops
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    or using strstr function

    PHP Code:
                    char *Source = new char[10];
                    
    char *Search = new char[1];
                    
    char *p1=0;
                    
    char *tmp = new char[30];

                    
    strcpy(Source"abcdef.ghi");
                    
    strcpy(Search".");

                    
    p1 strstr(SourceSearch);
                    if (
    p1 != NULL)
                    {
                        
    sprintf(tmp"Dot found at address %ld", &p1);
                        
    MessageBox(hDlgtmp"Search"MB_OK);
                    }
                    else
                    {
                        
    MessageBox(hDlg"No dot fuond.""Search"MB_OK);
                    } 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width