Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int strlent_test(const char* y);
- ////////////////////////////
- int main() //
- {
- char str[99] = "SONY Pictures 2";
- int n = strlent_test(str);
- printf("n = %d", n);
- return 0;
- }
- ///////////////////////////////////
- int strlent_test(const char* y) //
- {
- int i = 0;
- while( y[++i] != 0);
- return i;
- }
- /*
- ///////////////////////////////////
- int strlent_test(const char* y) //
- {
- int n = 0;
- while(*y != 0)
- {
- y++;
- n++;
- }
- return n;
- }
- */
- /*
- #include <stdio.h>
- void foo(char *p);
- /////////////////////////////////////////////////////////
- int main()
- {
- char sz[5] = "SONY";
- char *p = &sz[3];
- foo(p);
- }
- ////////////////////////////////////////////////////////
- void foo(char *p2)
- {
- for(int i = 4; i > 0; i--)
- {
- printf("%c", *p2);
- p2--;
- }
- }
- */
- /*
- #include <stdio.h>
- void foo(char *p);
- /////////////////////////////////////////////////////////
- int main()
- {
- char sz[5] = "SONY";
- char *p = &sz[3];
- foo(p);
- }
- ////////////////////////////////////////////////////////
- void foo(char *p2)
- {
- for(int i = 4; i > 0; i--)
- {
- printf("%c", *(p2-3));
- }
- }
- */
- // printf("%s \n", p2-1);
- // printf("%c\n", *p);
- // printf("%c\n", p[2]);
- // printf(" p= %s\n", p);
- /*
- #include <stdio.h>
- char sz[5] = "SONY";
- ///////////////////////////////////////////////////////
- int main() //
- {
- char *p = &sz[1];
- printf("%c\n", *p);
- printf("%s \n", &p[-1]);
- printf("%s \n", p -1 );
- //printf("%c\n", p[1]);
- //printf(" p= %s\n", p);
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement