1 / 7
文档名称:

大连东软信息学院大一上 电子工程 c语言-实验第六次,第十二周.doc

格式:doc   页数:7
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

大连东软信息学院大一上 电子工程 c语言-实验第六次,第十二周.doc

上传人:yzhlya 2016/7/1 文件大小:0 KB

下载得到文件列表

大连东软信息学院大一上 电子工程 c语言-实验第六次,第十二周.doc

文档介绍

文档介绍:Lab 7 Pointers OBJECTIVES pleting this experiment, you will be able to: ? Understand p ointers fundamentals ? Understand f unctions and pointers ?P ass arrays to functions ? Use p ointers to One-Dimensional Arrays PROCEDURES 1. What format speci ? ers (in order) should be used in the printf() statement in the following program? Note that in the program the correct format speci ? ers have been replaced by Z. #include <> int main(void) { intx= 5; int *x_ptr = &x; printf("%Z, %Z, %Z, %Z\n", x, *x_ptr, &x, x_ptr); } Your answers : (2 Marks) %d,%d,%p,%p —————————————————— Print Screen of Result: (3 Marks) 2. On a machine in which addresses are 2 bytes, what is printed by the following program: #include <> int main(void) char fun[] = "Programming is fun."; char favorite[] = "My favorite class is programming."; char *x= fun; printf("%d\n", sizeof(fun)); printf("%d\n", sizeof(favorite)); printf("%d\n", sizeof(x)); } Your answers : (2 Marks) 20342 —————————————————— Print Screen of Result: (3 Marks) 3. Rewrite the following program, replacing the subscript (index) notation with the corresponding pointer notation. Only change the parts of the program necessary for the replacement. #include <> int main(void) { int data[] = {1, 2,3,4,5, 6}; int i; for(i =0;i<6; i++) printf("%2d", data[i]); } Print Screen of Code: (6 Marks) —————————————————— Print Screen of Result: (3