All pastes #183954 Raw Edit

Miscellany

public c v1 · immutable
#183954 ·published 2006-09-27 12:05 UTC
rendered paste body
#include <stdio.h>#include <string.h>intmain(int argc, char **argv) {  char *sentence =  "500053 This is a string";  char *vhost;  char str1[8] ="";  int i;  //for(i=0;i < strlen(sentence) && sentence[i] != 32; i++);   for(i=0;sentence[i] != 0 && sentence[i] != 32; i++);  printf("stop-char(%d): '%c'\n",i,sentence[i-1]);  vhost = strncpy(str1,sentence,i);  char logentry[sizeof(sentence)-sizeof(vhost)];  for(++i; i < strlen(sentence); i++) {    logentry[i] = sentence[i];    printf("logentry[%c] = sentence[%c]\n",logentry[i],sentence[i]);  }  printf("input is: %s\n",sentence);  printf("vhost is: '%s'\n",vhost);  printf("logentry is: '%s'\n",logentry);}