From the course: Complete Guide to C Programming Foundations

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Sending string output

Sending string output

- [Instructor] In this exercise file, I've concocted my own string output function using a while loop in the putchar function, a string literal is declared at line five. The while loop condition states that the loop repeats as long as the value of character in element A isn't equal to the null character, which the compiler automatically appends to the end of the string literal here. The putchar function sends a single character from the string to standard output. Variable A is incremented, which keeps the loop marching through the string. Run to see the output. And there's the output. The C language can be delightfully cryptic, and this code can show you how that works. Because the putchar function also returns the character it sends to standard output, I can set the function into the while loops condition, and I can delete the statement here. The test is the same and the output is unchanged, and you are a handsome program, but you could use more improvement. The null character test…

Contents