while loop question

void flashSequence(char *sequence)

int i = 0;
while (sequence != NULL)

  • {*
    _ flashDotOrDash(sequence*);_
    _ delay(dotDelay * 3); // gap between letters_
    This is the part of the code I am having trouble understanding how it works. So flashSequence variable has a value of “.-” which gets turned into the variable called “sequence” in the parenthesis, got that, but can someone explain what the while statement line means for me? Thank you
    If you want more information let me know, it is an example from a beginners book

Are the italics important?

Please remember to use code tags when posting code

I just figured it out, it is turning the char variable into an array (or a list?, one of the two) and executing the flash sequence for each individual character using i to run thru the order of the array starting at 0. Thank you thought

There is no char variable.
There is a char pointer.

Your code makes no sense as posted. The forum software ate the array index ([I]). Read the forum guidelines to see how to post code (see #7).

// Call 'flashDotOrDash()' for each character in a string
void flashSequence(char *sequence)
  int i = 0;  // Start at the beginning of the string

  //  Repeat until we reach the end of the strig
  while (sequence[i] != NULL)
    // Call flashDotOrDash() for this character
    i++;  // Go on to the next character
  // Then put in an inter-character gap
  delay(dotDelay * 3);    // gap between letters