TAILIEUCHUNG - C Programming for the Absolute Beginner phần 8

Tham khảo tài liệu 'c programming for the absolute beginner phần 8', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 9 Introduction to Data Structures emp emp emp1 5 To access individual elements in a structure array you need to provide the array element number surrounded by brackets. To access individual structure members you need to supply the dot operator followed by the structure member name as revealed in the next segment of code which uses the strcpy function to copy the text Spencer into the memory reserved by the structure member. strcpy emp1 0 .fname Spencer The next program and its output shown in Figure demonstrate arrays of structures in more detail. i nclude i nclude typedef struct scores char name 10 int score s main s highScores 3 int x assign values to members strcpy highScores 0 .name Hunter highScores 0 .score 40768 strcpy highScores 1 .name Kenya highScores 1 .score 38565 strcpy highScores 2 .name Apollo C Programming for the Absolute Beginner Second Edition highScores 2 .score 35985 print array content printf nTop 3 High Scores n for x 0 x 3 x printf n s t d n highScores x .name highScores x .score end main figure Creating and using arrays of structures. Passing Structures to Functions To utilize the power of structures you need to understand how they are passed to functions for processing. Structures can be passed to functions in a multitude of ways including passing by value for read-only access and passing by reference for modifying structure member contents. Passing by value protects an incoming variable s value by sending a copy of the original data rather than the actual variable to the function. Passing by reference sends a variable s memory address to a function which allows statements in the function to modify the original variable s memory contents. Passing Structures by Value Like any parameter passed by value C makes a copy of the incoming structure variable for the function to use. Any modifications made to the parameter within the receiving function are not made to the original variable s value. To pass a .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.