Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Navrhnete funkci
- char *Obrat(char *text);
- Ktera zjisti delku predavaneho textu,
- podle delky si alokuje pomocne pole a do tohoto pole
- zkopiruje predavany text pozpatku. Pak ho zkopiruje zpet do
- parametru text. V main vyzkousejte.
- */
- #include<stdio.h>
- #include<conio.h>
- #include<stdlib.h>
- #include<string.h>
- char* Obrat(char* text);
- void main()
- {
- char text[100];
- printf("Zadejte libovolny text: ");
- gets(text);
- text = Obrat(text);
- printf("%s",text);
- getch();
- }
- char* Obrat(char* text)
- {
- int i, size = strlen(text);
- char text2[size + 1];
- for(i = 0; i < size; i++)
- {
- text2[i] = text[size - i - 1];
- }
- text2[i] = 0;
- strcpy(text,text2);
- return text2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement