All pastes #804140 Raw Edit

Untitled

public text v1 · immutable
·published 2007-12-03 03:52 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {

	struct foo {
		char name[30];
		int dongs;
	} bar;

	bar.name = "I lieks teh cock"; /* wrong */

	memset(bar.name, 0, 30);
	strncpy(bar.name, "I lieks teh cock!", 29); /* correct */

	return 0;
}