[ create a new paste ] login | about

Link: http://codepad.org/3GYLvvUR    [ raw code | output | fork ]

C, pasted on Feb 11:
#include <stdio.h>
#include <string.h>

int main()
{
   char *buff = "\"{\"action\":\"UPDATE\",\"frameId\":\"1\",\"partitionNumber\":\"1\",\"partitionSequence\":\"1\",\"tableAlias\":\"X\",\"rowNumber\"";
   char *verb = "frameId";
   int i =0;
   char *str = strstr(buff, verb);
   
   char *tempbuff = (char *) malloc(strlen(buff));
   memcpy(tempbuff, buff, strlen(buff));
   
   printf("len str: %d\n", strlen(str));
   printf("len buff: %d\n", strlen(buff));
   //printf("%s\n", str+strlen(verb)+3);
   
   char *ptr = (char *) malloc(strlen(buff));
   tempbuff = str+strlen(verb)+3;
   
   printf("%s\n", tempbuff);
   
   for(i; i < 20; i++){
      if(tempbuff[i] == '\"'){
         ptr[i] = '\0'; 
         break;
      }else {
          ptr[i] = tempbuff[i];
      }
   }
   
     printf("%s\n", ptr);
 // printf("%s\n", tempbuff);
   
   

    return 0;
}


Output:
1
2
3
4
len str: 87
len buff: 108
1","partitionNumber":"1","partitionSequence":"1","tableAlias":"X","rowNumber"
1


Create a new paste based on this one


Comments: