STRINDEX.C
Upload User: qq5388545
Upload Date: 2022-07-04
Package Size: 29849k
Code Size: 0k
Category:

GUI Develop

Development Platform:

C/C++

  1. #include <stdio.h>
  2. int str_index(const char *string, int letter)
  3.  {
  4.    char *original = string;
  5.    while ((*string != letter) && (*string))
  6.      string++;
  7.    return(string - original);
  8.   }
  9.  void main(void)
  10.   {
  11.     printf("Location of C is %dn", str_index("1001 C/C++", 'C'));
  12.     printf("Location of x is %dn", str_index("1001 C/C++", 'x'));
  13.   }