well, I came up with this code after I got to wondering exactally how all this buffer/ string stuff behaved. I wanted to figure out if there was a quick way to see if a buffer had overrun its lenght with a strlen() (there is!! YAY!!!) check out this little snippet: ---8<------->8--- #include <stdlib.h> #include <stdio.h> #include <string.h> void main(void) { int i=0; char test[10]=" "; printf("\nlength: %d .%s.\n",strlen(test),test); for(i=0;i<=strlen(test)+1;i++) printf("char %2d: %3d .%c.\n",i+1,test[i],test[i]); strcpy(test,"test"); printf("\nlength: %d .%s.\n",strlen(test),test); for(i=0;i<=strlen(test)+1;i++) printf("char %2d: %3d .%c.\n",i+1,test[i],test[i]); strcpy(test,"1234567890abcd"); printf("\nlength: %d .%s.\n",strlen(test),test); for(i=0;i<=strlen(test)+1;i++) printf("char %2d: %3d .%c.\n",i+1,test[i],test[i]); strcpy(test,"test"); printf("\nlength: %d .%s.\n",strlen(test),test); for(i=0;i<=15;i++) printf("char %2d: %3d .%c.\n",i+1,test[i],test[i]); exit(0); } give it a spin... kinda interesting... esp the length of the 3rd string and the contents of the 4th. --Angus +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST