Hello
im trying to count and show the same chars that in the string
when im done to count i want enter the number to a new string but i get garbage instead
pls help,thx (: (third row from the end)
[
]
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#define N 100
void doArchive (char * str, char * dest);
void main()
{
char str[N],dest[N];
printf("Enter your string : ");
gets(str);
doArchive(str,dest);
}
void doArchive(char * str, char * dest)
{
int sc,j,dc,numOfStr=strlen(str),count=0;;
for(sc=0,dc=0;sc<numOfStr;sc++)
{
dest[dc]=str[sc];
for(j=0;str[sc]==str[j];j++)
{
count++;
if(count>9)
{
dest[dc+1]='9';
dest[dc+2]=dest[dc];
dc+=3;
count=1;
}
}
dest[dc+1]=count;
dc+=2;
sc=j;
}
}