Search
 
SCRIPT & CODE EXAMPLE
 

C

how compress string in c

char* StrCompress(char myStr[])
{
  char *s, *in;
  for (s = myStr, in = myStr; *s; s++) {
    int count = 1;
    in[0] = s[0]; in++;
    while (s[0] == s[1]) {
      count++;
      s++;
    }   
    if (count > 1) {
      int len = sprintf(in, "%d", count);
      in += len;
    }   
  }
  in[0] = 0;
  return myStr;
}
Comment

PREVIOUS NEXT
Code Example
C :: print to console in c 
C :: how to change background color in c programming 
C :: array of strings in c 
C :: set the nth bit 
C :: how to empty array in c 
C :: calculate median 
C :: transfer function exponent matlab 
C :: KneesDev 
C :: c program to implement mv command 
C :: cifras de un numero en c 
C :: adding a node in the front on a linked list 
C :: definir função em c 
C :: create arrya of chars malloc 
C :: c size_t 
C :: bool c++ 
C :: oracle trunc 
C :: pointer c 
C :: c malloc 
C :: c sjf 
C :: obstacle avoiding robot in c++ program 
C :: how to belu-roll peoples in c 
C :: main prototype 
C :: how to get out of function in c 
C :: code_art_bcm_10.c 
C :: curl ftp upload file to directory 
C :: como hacer para que una salida en linux aparezca de poco en poco 
C :: counting 7s in an integer c 
C :: Sum of upper & lower triangles elements 
C :: c Modulo 10^9+7 (1000000007) 
C :: debian9 remove pack 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =