Advertisement
Adijata

how to do it on ispit without drugog parametra(string obrni)

Sep 10th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #define size 80
  5.  
  6. char* obrni( char rijec[])
  7. {
  8.     char novi[50];
  9.     char *s=novi;
  10.     char*p=rijec;
  11.     int broj;
  12.  
  13.  
  14.     while(*p!='\0')
  15.     {
  16.         if(*p>='0' && *p<='9')
  17.         {
  18.             broj=0;
  19.             while(*p>='0' && *p<='9')
  20.             {
  21.                 broj*=10;
  22.                 broj+=(int)(*p-'0');
  23.                 p++;
  24.             }
  25.             while(broj!=0)
  26.             {
  27.                 *s=(char)(broj%10+'0');
  28.                 broj/=10;
  29.                 s++;
  30.             }
  31.  
  32.         }
  33.         *s++=*p++;
  34.     }
  35.      *s='\0';
  36.  
  37.      strcpy(rijec, novi);
  38.  
  39.     return rijec;
  40. }
  41.  
  42. int main()
  43. {
  44.     char niz[50] = "Hrk255ljus789";
  45.  
  46.     char *p=niz;
  47.     p=obrni(niz);
  48.  
  49.     while(*p!='\0')
  50.     {
  51.         printf("%c", *p++);
  52.     }
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement