Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- #include <math.h>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- char text[]="color=blue&icon=search.png&number=95684&submit=plus";
- char output[300];
- int main(int argc, char *argv[]) {
- char *pch =strtok(text,"&=");
- char imgbegin[] = "<img height='200px' width='200px' alt='img' src='img/";
- char imgend[]=".png'>\n";
- char imgnum[12],imgnumr[12];
- int num,n,x,k=0,randn,imgval=5;
- while (pch!=NULL) {
- if (strcmp(pch,"number")==0) {
- pch = strtok(NULL,"&=");
- break;
- }
- pch = strtok(NULL,"&=");
- }
- num=atoi(pch);
- x=num;
- while (x!=0) {
- x=x/10;
- k++;
- }
- // printf("%d\n",k);
- srand(time(NULL));
- while (k!=0) {
- n=(num%(int)pow(10,k))/(int)pow(10,k-1);
- randn=rand()%imgval;
- sprintf(imgnum,"%d",n);
- sprintf(imgnumr,"%d",randn);
- strcat(output,imgbegin);
- strcat(output,imgnum);
- strcat(output,imgnumr);
- strcat(output,imgend);
- k--;
- }
- printf("%s\n",output);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement