int main(void)

{

char string[15];

char *ptr, c = 's';

strcpy(string, "This is a string");

ptr = strchr(string, c);



if (ptr)

printf("The character %c is at position: %d\n", c, ptr-string);

else

printf("The character was not found\n");

return 0;

}

c Language ,strchr(), Find more articles about where the first character appears in a string

  1. JavaScript Find the position and number of times a given character appears in a string

    requirement : Given string oabcoefoxyozzopp, Output character required o The location and number of occurrences . Realize the idea : Find the first one first o Position of appearance And then just judge indexOf The result returned , If it is not -1, Then continue to search later because ind ...

  2. C Language : Output the characters in the string in reverse order , But don't change the contents of the string .- stay main Function will be called many times fun function , Every call , Output the data in the tail node of the linked list , And release the node , Shorten the list .

    // Output the characters in the string in reverse order , But don't change the contents of the string . #include <stdio.h> /************found************/ void fun (char ...

  3. SQL Server Find the number of times the specified character appears in the string

    To find where a specified character appears in a string , The method is simple , Use len() Functions and replace() Function combination can . SELECT TOP 200 approveInfo approveInfo2, ...

  4. utilize Mysql Provides a string method to find the number of times a character appears in a string

    There is such a need , Find out the first level classification without sub classification , The first solution in my mind and this First use PHP Find out all the primary categories Recursively query whether the first level classification has sub classification Summarize the first level classifications without subcategories But I think it's too much trouble , then ...

  5. JS Find the most frequently occurring character in a string

    This article brings you two kinds of ideas js Find the most frequently occurring character in a string , In these two methods, the second one is recommended , Yes js Find the number of string related knowledge, interested friends to see it   In a string , Such as 'zhaochucichuz ...

  6. Javascript Find the most characters and times in a string

    <script type="text/javascript"> // Find the most characters and times in a string var str = 'Thatwheneying its o ...

  7. php Find the location of the first Chinese character in the string , And insert the string

    // Find the location of the first Chinese character in the string , And insert the string function find_first_chinese_insert($str,$insert_str){ $count = mb_strle ...

  8. Use Java Find the most frequently occurring character in a string and the number of occurrences ?

    Use Java Find the most frequently occurring character in a string and the number of occurrences ? import java.util.HashMap; import java.util.Map; public class TestStr ...

  9. The finger of the sword offer- Chapter five optimizing time and space efficiency ( A character that first appears in a string and only appears once )

    subject : A character that first appears in a string and only appears once Ideas : use HashMap To store the corresponding char Value and the char Number of occurrences . Do a variable once and you'll get the first character that appears only once . Java Code : import java. ...

Random recommendation

  1. Spark Core Source code analysis : Spark Task model

    summary One Spark Of Job Divided into several stage, the last one stage Will contain one or more ResultTask, Ahead stages Will contain one or more ShuffleMapTasks. ResultTask Run and will ...

  2. Sharing is very useful Java Program ( Key code )( 6、 ... and )--- analysis / Read XML file ( important )

    original text : Sharing is very useful Java Program ( Key code )( 6、 ... and )--- analysis / Read XML file ( important ) XML file <?xml version="1.0"?> <student ...

  3. Intermediary model Mediator Mediator Behavior type Design patterns ( The 21st )

      Intermediary model (Mediator)   Dispatch . Mediate   Intention Use a mediation object ( Intermediary ) To encapsulate a series of object interactions , Mediators make it unnecessary for objects to explicitly refer to each other , So that the coupling is loose And they can change their interaction independently . ...

  4. centos7.5 Compile and install under environment php7.0.30 And install redis and mongo Expand

    . install php7..30 Script for # vim install_php.sh #!/bin/bash # Installation depends on yum install -y gcc gcc-c++ htop telnet ioto ...

  5. 2018 The latest search engine jump JavaScript Code ( Special for competitive advertising )

    JavaScript The code is as follows , Please put it in script tag : eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.r ...

  6. php page No error prompts are displayed

    error_reporting(0); ini_set('html_errors',false); ini_set('display_errors',false);

  7. CentOS7 install svn

    1 yum install subversion 2 function svn --version Report errors svn: error while loading shared libraries: libaprutil ...

  8. 【HEOI 2018】 Linkcat tree

    Reprint please indicate the source :http://www.cnblogs.com/TSHugh/p/8776179.html First say 60 Points of . The thinking is very clear : The question seems to be equivalent to choosing K+1 A chain of disjoint points !F(x,k,0/1/ ...

  9. hdu 3496 Watch The Movie ( Two dimensional backpack )

    Watch The Movie Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)T ...

  10. MySQL Skillfully use FIND_IN_SET and GROUP_CONCAT Function reduction Java The amount of code

    Introduction to database tables : List of items `id` int(11)  ' goods id, Unique identification ', `name` varchar(255) ' Item name ', `level` int(11) ' Item category level , Gift bag is the most advanced 1, class ...