tailieunhanh - C Programming for Scientists & Engineers phần 3

mà nó đọc vào những vị trí cụ thể trong bộ nhớ. Quan trọng hơn, fscanf cần phải được cho biết nơi để đặt các dữ liệu mà nó đọc. Cách dễ nhất để làm điều này là để khai báo một biến trước và nói "đưa các dữ liệu tại địa chỉ của biến đó. Hiệu quả tổng thể của việc này là để lưu trữ các | 24 c programming tor scientists and engineers used to read the name from the keyboard. Note that the control string for fscanf contains a new formatting code s. This tells fscanf to interpret the input as a character string. This should be compared with the formatting code c introduced in Section required for single characters. A further point to note in the call to fscanf in Program is that the name of the character string A is not preceded by . This only works for character strings and is allowed because the name of an array is actually a pointer to the first byte in the array. As an alternative to this we could use the approach demonstrated in Program where the address of each array element is specified plicidy However his is inefficient for character strings. REMEMBER that Cưeạts character strings differently to variables of other dam types in that ficanfdaa not need in front of the name of the Chirac er string Hence as shown in Program bothA and ri just need the name of the character string as an argument. A farther point to note when reading dam into character strings is that a character string is defined as a continuous sequence of symbols. -Thus John is a single character string buCJohn Smith consists of two Chara ter strings. The result of typing either of these as input to Program would be the same the output on the screen would be Your name is John . Tutorial Implement Program . Write brief notes on the action of each statement in the program. Tutorial Using Program as a guide implement a program that roads and writes an array of five words each containing up to 10 characters. Data structures Suppose that we need a program that reads collections of data from the user and displays their values on the screen. For example each collection could refer to an employee in a company consisting of Team-Fi Variables data types and declaration statements 25 their employee number family name and salary. The most appropriate .

TỪ KHÓA LIÊN QUAN