I'm just learning c and I barely understand what I'm doing. I have a buffer and I want to chop a word off the front, one at a time and then do something with it. Guess, I need a pointer to the buffer and be able to move it around and do I need to free anything? Cause, eventually, I'll have a while loop getting input from the user, taking the input, and chopping it up into words.

Code:
#include <stdio.h>
#include <string.h>


void pull_word(char *cmd, char delim) {
  int i = 0;
  
  for (i = 0; i < strlen(cmd); i++) {
      if (cmd[i] == delim) break;
      printf("%c", cmd[i]);
  }
}


char *buffer = "ls a b c";


int main()
{
    pull_word(buffer, ' '); //would print ls a b c
    
    pull_word(buffer, ' '); //would print a b c


    return 0;
}