Angel David Yaguana Hernandez
/
CPP_strncmp
strncmp, descripcion y ejemplo
main.cpp@0:7ab6d00922fa, 2012-04-03 (annotated)
- Committer:
- sherckuith
- Date:
- Tue Apr 03 21:05:19 2012 +0000
- Revision:
- 0:7ab6d00922fa
strncmp, descripcion y ejemplo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sherckuith | 0:7ab6d00922fa | 1 | #include "mbed.h" |
sherckuith | 0:7ab6d00922fa | 2 | /* strncmp example */ |
sherckuith | 0:7ab6d00922fa | 3 | #include <stdio.h> |
sherckuith | 0:7ab6d00922fa | 4 | #include <string.h> |
sherckuith | 0:7ab6d00922fa | 5 | |
sherckuith | 0:7ab6d00922fa | 6 | int main () |
sherckuith | 0:7ab6d00922fa | 7 | { |
sherckuith | 0:7ab6d00922fa | 8 | char str[][5] = { "R2D2" , "R2PO" , "R2A6", "R2xx" }; |
sherckuith | 0:7ab6d00922fa | 9 | int n; |
sherckuith | 0:7ab6d00922fa | 10 | puts ("Looking for R2 astromech droids..."); |
sherckuith | 0:7ab6d00922fa | 11 | for (n=0 ; n<4 ; n++)// 4 es numero de elementos |
sherckuith | 0:7ab6d00922fa | 12 | if (strncmp (str[n],"R2xx",2) == 0) |
sherckuith | 0:7ab6d00922fa | 13 | { |
sherckuith | 0:7ab6d00922fa | 14 | printf ("found %s\n",str[n]); |
sherckuith | 0:7ab6d00922fa | 15 | } |
sherckuith | 0:7ab6d00922fa | 16 | return 0; |
sherckuith | 0:7ab6d00922fa | 17 | } |