#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main()
{
char input[100] = "", c, x;
int i = 0, num = 0;
printf("Enter the input (char followed by its occurrence)\n");
scanf("%s", input);
while ((c = input[i++])) {
if ((c >= 'a' && c <='z') || (c >= 'A' && c <= 'Z')) {
x = input[i];
while(isdigit(x)) {
num = (num * 10) + (x - '0');
x = input[++i];
}
while(num--)
printf("%c", c);
num = 0;
}
}
printf("\n");
return 0;
}
Here is the expected output for given input
input: a10b5c4
output: aaaaaaaaaabbbbbcccc