Join Eduardo Corpeño for an in-depth discussion in this video String conversion example, part of C Standard Library.
- [Instructor] Now let's see these functions in an example.…This example has three parts.…In the first one, we'll see atoi,…as you can see in the comments.…In the second one, we'll see STR to long,…and in the third one, sscanf.…So let's get started with atoi.…As you can see in line six, we have str1,…which is a string that contains a representation…for the number 572.…So if I want to convert that string to a number,…I can use atoi, so let me do that in line seven.…
I will assign to a new integer value that's called an X…the return value of atoi, with an argument of str1.…That's it.…So that's the beauty of atoi.…It's very simple to use.…Now let's print it out.…Let me say X equals this value,…and the variable will be X.…
That's it for part one.…Now let's get to part two, where we will use…STR to long.…Now, if you look at the string in line 11,…you'll see that str2 has two numbers.…The first one is a decimal number 123,…that's what I meant by it, and the second one…is a hexadecimal number 3A.…So we will extract those two numbers from the string…
- 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.