All pastes #950106 Raw Edit

Anonymous

public c v1 · immutable
·published 2008-03-20 10:19 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>int main(){	FILE *f;	char *buf;	char ch;	int i=0;	char str[] = "String to operate with";	f = fopen("./read.txt",  "r");	for (;i<5 ;i++ )	{		fseek(f,0,SEEK_SET);		ch = fgetc(f);		str[i] = ch;	}	/*		int len = (int)strlen(str);		buf = (char *)malloc(len);		f = fopen("./read.txt",  "r");		fgets(buf, len, f);		printf("received: '%s'\n", buf);		fclose(f);	*/	f = fopen("./write_binary.txt", "wb");	fwrite(str, sizeof(char), 50, f);	fclose(f);	return 0;}