strchr, descripcion y ejemplo
Revision 0:8b9477b27450, committed 2012-04-03
- Comitter:
- sherckuith
- Date:
- Tue Apr 03 21:04:22 2012 +0000
- Commit message:
- strchr, descripcion y ejemplo
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Apr 03 21:04:22 2012 +0000
@@ -0,0 +1,28 @@
+#include "mbed.h"
+/* strchr example */
+#include <stdio.h>
+#include <string.h>
+
+int main ()
+{
+ char str[] = "This is a sample string";
+ char * pch;
+ printf ("Looking for the 's' character in \"%s\"...\n",str);
+ pch=strchr(str,'s');
+ while (pch!=NULL)
+ {
+ printf ("found at %d\n",pch-str+1);
+ pch=strchr(pch+1,'s');
+ }
+ return 0;
+}
+
+/*
+Output:
+
+Looking for the 's' character in "This is a sample string"...
+found at 4
+found at 7
+found at 11
+found at 18
+*/
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Apr 03 21:04:22 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/737756e0b479