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 - C Tutorial
From the course: Complete Guide to C Programming Foundations
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
-
-
-
-
-
-
-
-
-
Using single character I/O3m 32s
-
(Locked)
Testing and converting characters3m 15s
-
(Locked)
Challenge: Character I/O and conversions34s
-
(Locked)
Solution: Character I/O and conversions1m 37s
-
(Locked)
Understanding strings in C2m 46s
-
(Locked)
Fetching string input3m 45s
-
(Locked)
Sending string output3m 41s
-
(Locked)
Challenge: Using printf placeholders1m 9s
-
(Locked)
Solution: Using printf placeholders1m 59s
-
(Locked)
Exploring string functions2m 41s
-
(Locked)
Manipulating strings2m 57s
-
(Locked)
Chapter challenge: Reading commands1m 52s
-
(Locked)
Chapter solution: Reading commands2m 31s
-
-
-
-
-