Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Передайте Си-строку в функцию. Пусть функция поменяет местами
- // первую и последнюю букву, в переданной Си-строке.
- #include <stdio.h>
- #include <string.h>
- void foo(char *pc);
- //////////////////////////////////////////
- int main() //
- {
- char sz[99] = "SONY Pictures";
- foo(sz);
- printf("%d\n", &sz[0]);
- printf("%d\n", &sz[1]);
- printf("%s\n", sz);
- }
- ///////////////////////////////////////////
- void foo(char *pc) //
- {
- int nLen = strlen(pc) - 1;
- char c = *pc;
- *pc = pc[nLen];
- pc[nLen] = c;
- }
- //printf("c = %c\n", c);
- // printf("nLen = %d\n", nLen);
- /*
- #include <stdio.h>
- void foo(char *pc);
- //////////////////////////////////////////
- int main() //
- {
- char sz[99] = "SONY";
- foo(sz);
- printf("%s\n", sz);
- }
- ///////////////////////////////////////////
- void foo(char *pc) //
- {
- char c = *pc;
- *pc = pc[3];
- pc[3] = c;
- //printf("c = %c\n", c);
- }*/
- /*
- #include <stdio.h>
- //////////////////////////////////////////
- int main() //
- {
- int narr[] = {5, 12, 17, 23, 42, 54, 67, 79},
- size = sizeof(narr) / sizeof(narr[0]),
- index = -1,
- *address = 0;
- for(int i = 0; i < size; i++)
- {
- if (narr[i] == 17)
- {
- index = i;
- address = &narr[i];
- goto L_01;
- }
- }
- L_01: printf("%d\n", index);
- printf("%d\n", address);
- int *p = address;
- p = p - 2;
- printf("p = %d\n", p);
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement