All pastes #916397 Raw Edit

stefys

public c v1 · immutable
#916397 ·published 2008-02-24 16:38 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include <string.h>void trim (char *str){	printf("STR: %s\n", str);	char *a, *b;	a = strchr(str, '\n');	b = strchr(str, '\r');	if (a == NULL && b == NULL) return;	else *( (a-str) < (b-str) ? a : b) = '\0';}int main(void) {	char *str;	str = malloc(7);	str = strdup("\nhello");	trim(str);	printf("-%s-\n",str);	system("pause");	return EXIT_SUCCESS;}