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>
- int main(){
- setbuf(stdout,NULL); //disable output buffering
- char *str=malloc(9);
- strcpy(str,"abcdefgh");
- str=realloc(str,strlen(str)+1+8);
- strcat(str,"efghefgh"); //sprintf(str,"%s%s",str,"efghefgh");
- unsigned int imax=1024/strlen(str)*1024*4;
- printf("%s","exec.tm.sec\tstr.length\n"); //fflush(stdout);
- time_t starttime=time(NULL);
- char *gstr=malloc(0);
- unsigned int i=0;
- size_t lngth;
- char *pos_c=gstr;
- size_t str_len=strlen(str);
- while(i++ < imax+1000){
- lngth=strlen(str)*i;
- gstr=realloc(gstr,lngth+str_len);
- strcat(gstr,str); //sprintf(gstr,"%s%s",gstr,str);
- pos_c=(gstr + (str_len * (i - 1)));
- while((pos_c=strstr(pos_c,"efgh"))){
- memcpy(pos_c,"____",4);
- }
- if(lngth % (1024*256)==0){
- printf("%lusec\t\t%lukb\n",time(NULL)-starttime,lngth/1024); //fflush(stdout);
- }
- }
- //printf("%s\n",gstr);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement