课程: Complete Guide to C Programming Foundations

今天就学习课程吧!

今天就开通帐号,24,100 门业界名师课程任您挑!

Specifying integers and real numbers

Specifying integers and real numbers

- [Instructor] Numbers in C come in two flavors. The INT data type stores integers, or whole number values, the float and double data types store real numbers, are those that contain a decimal portion or are very large or very small. Integer literals are written without commas as shown in line 5. For real numbers, always specify the decimal part. At line 6, float value, 0.25, is written as 0.25. At line 7, the real value 1 billion, no commas, has a trailing dot zero. This format, dot zero and zero dot inform the compiler that the literal value is a float or double number. This exercise file provides a quick test, run it. That'll type 100 million and it works. Now I'm going to run it again, but I'm going to type a comma. You see the value is truncated from what was input, not what you want. At line 10, the fgets function reads a string of characters into the buffer character array. The strtol function converts the string into a value stored in variable lv. This function doesn't…

内容