I want to copy a string into a char array, and not overrun the buffer.
So if I have a char array of size 5, then I want to copy a maximum of 5 bytes from a string in
char mystring[101]; // a 100 character string plus terminator char *any_input; any_input = "Example"; iterate = 0; while ( any_input[iterate] != '\0' && iterate < 100) { mystring[iterate] = any_input[iterate]; iterate++; } mystring[iterate] = '\0';
This is the basic efficient design.