All pastes #713914 Raw Edit

Someone

public c v1 · immutable
#713914 ·published 2007-09-25 19:45 UTC
rendered paste body
#include <stdio.h>char ringbuffer[9][9]; //char matrix with size for 10char stringsint nextToPut=0;int nextToGet=0;void put(char* c){	int i=0;	while(i<9){		ringbuffer[nextToPut][i]=c[i];		i++;	}	printf("string copied\n");	nextToPut++;	}char* get(void){	if((ringbuffer[nextToGet]!=NULL)){		nextToGet--;		nextToPut--;		return ringbuffer[nextToGet+1];	}	else{		return NULL;	}}int main(){	char* pChar;	char* myString="hello";	char* myString2="hellow";	put(myString);	put(myString2);	pChar=get();	printf("char is:%s\n",pChar);	pChar=get();	printf("char is:%s\n",pChar);}OUTPUT:bkw@sandbox:~/code/buffertest$ ./a.outstring copiedstring copiedchar is:hellochar is: