I think it's better if u use sscanf %c%d%s -> ch, count, tempString And do it till the temporary string is empty...
Then for every set of itteration you just need to make a nested loop to print ch as count times... It's easier I think... Regards.. -- WickedBerry® Pow3r3D bY XL GPRS network -----Original Message----- From: anuraag dimri <[EMAIL PROTECTED]> Date: Wed, 22 Aug 2007 18:19:07 To:[email protected] Subject: [c-prog] decomress a string "a2b3c4" to aaaabbbcccc Hi there, i tried sumtyn like decompressing a4b7c2 in to aaaabbbbbbbcc...didnt worked... i'm storing it in an array of big size and then trying to first shift b7c2 and then expand a4..is it acceptable.. heres the code...the numbers i have assumed to be single digit numbers in the original string. int main() { char s[100]="a4b6c8"; int i,j,k,l; l=strlen(s); for(i=j=0; s[i]!='\0';i++) { if(s[i] >= 'a' && s[i] <= 'z') s[j++]=s[i]; if(s[i] >= '0' && s[i] <= '9') { k = s[i]-48; while(i<l) { s[l+(k-2)]=s[l]; l--; } s[l+(k-1)]='\0'; /*marking the new end of string*/ } while((k-2)>0) {/*some problem here may b*/ s[--j]=s[--i]; k--; } } s[j]='\0'; printf("\n%s",s); } --------------------------------- Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out. [Non-text portions of this message have been removed] To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/c-prog/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/c-prog/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
