All pastes #756203 Raw Edit

Something

public c v1 · immutable
#756203 ·published 2007-10-31 08:52 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include <string.h>void separateInput(char *inputString, int IDArray[], char *outputString);int main(){   int IDArray[3];   char data[90] = "bla";   separateInput("123:433:oifenso:ifoes933", IDArray, data);   printf("test:\nMessage ID %d\nPacket ID %d\nData %s\n", IDArray[0], IDArray[1], data);}void separateInput(char *inputString, int IDArray[], char *outputString){   char * pointchar;   int pointint;   char string1[98];   int messageid;   int packetID;   char data[90];   char tmp[3];   strcpy(string1, inputString);//Find first occurrence of :   pointchar = strchr(string1, ':');   pointint = pointchar -string1+1;   //copy to messageID   strncpy(tmp, string1, pointchar-string1);   tmp[pointchar-string1] = '\0';   messageid = atoi(tmp);   //Remove message ID from line.   strcpy(string1, (string1 + sizeof(char)*pointint));//Find the next occurrence of :   pointchar = strchr(string1, ':');   pointint = pointchar -string1+1;//Copy to packetID   strncpy(tmp, string1, pointchar-string1);   tmp[pointchar-string1] = '\0';   packetID = atoi(tmp);//Remove packetID from message.   strcpy(data, (string2 + pointint));//  data = (char *)&string1;  printf("bla %s\n", data);  /* Populate the output */   IDArray[0] = messageid;   IDArray[1] = packetID;   outputString = data;}