1: #include <stdio.h>
2: #include <string.h>
3: main()
4: {
5: char *str = "aabbcc***^^^^&&&&ffff";
6: char opstr[100] = {0};
7: char c,tb[5];
8: int count = 1;
9: while(*str)
10: {
11: if ( *str == *(str +1) )
12: {
13: c = *str;
14: str++;
15: count++;
16: } else {
17: sprintf(tb,"%d",count);
18: strcat(opstr,tb);
19: sprintf(tb,"%c",c);
20: strcat(opstr,tb);
21: str++;
22: count=1;
23: }
24: }
25: printf("%s\n",opstr);
26: }
RTOS, Linux Kernel internal, OS-Programming C & Data Structures, Debugging, Optimizations, Makefiles and Wireless Technologies (Wi-Fi ,LTE and LTE-Advanced )
Search This Blog
Wednesday, October 28, 2015
Write a program which count all consecutive characters in a given string and write display string as in given example. e.g str = "aaabbbcc"; O/P string is "3a3b2c"
Labels:
C
Subscribe to:
Post Comments (Atom)
tb means what&5th line how to taken explainig
ReplyDelete