Join Eduardo Corpeño for an in-depth discussion in this video Unformatted I/O example, part of C Standard Library.
- [Instructor] In this code I have already included stdio.h…which is the header file that contains…the functions we are interested in.…As you can see in the main function,…we have two variable definitions,…one character c and one string str of length 20.…Now I will write some code for an echo application…which will take in a single character and print…that character out and then it will take a string…of characters and print that string out.…
So writing the character echo is quite simple.…As you can see in line 6, you just have to assign…to c the result of getchar.…Next, printing out the character is just as easy,…you just have to call putchar…and send the character as an argument.…That's it for the character echo.…Now before we get to the string echo,…I have to take care of a lingering character,…which is a newline character that came in when I hit Enter…at the time the character was typed in.…
I can do that by calling getchar…and discarding it's return value.…Next, let me separate the character echo…and the string echo by sending out a newline character,…
- Working with header files
- C constants and types
- Unformatted and formatted input/output
- Accessing files with C functions
- Generating random numbers
- Converting strings
- Sorting and searching for data
- Manipulating strings
- Using mathematical functions
Skill Level Intermediate
1. The C Standard Library
2. Input and Output Library: stdio.h
3. General Purpose: stdlib.h
4. String Functions: string.h
5. Mathematical Functions: math.h
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.