首页 技术 正文
技术 2022年11月7日
0 收藏 547 点赞 576 浏览 1436 个字
#include<stdio.h>void main()
{
puts("hello world");
int x=4;
//the %p format will print out the location in hex(base lb) format
printf("x lives at %p\n",&x);
int * addr_of_x = &x;
printf("x lives at %p\n",addr_of_x);
printf("the content of addr_of_x is %d\n",*addr_of_x);printf("the size of int is %d\n",sizeof(int));
char quote[]="turtles!";
// this will return 9, which is 8 characters plus the \0 end character
printf("the size of int is %d\n",sizeof(quote));
//why pointers have types?
/**
different data types has different size, when you do pointer arithmetic,
the compiler will not know how to increce the value when you not specify
the concrete data type of the pointer.
**/
int doses[] = {1, 3, 2, 1000};
printf("Issue dose %i\n", 3[doses]);
/*
char name[40];
printf("Enter your name: ");
scanf("%39s",name);
printf("your name is :%s\n",name);
int age;
printf("Enter your age: ");
scanf("%i\n", &age);
printf("your age is :%i\n",age);
//be careful with this , if your input is bigger than your variable to hold it.
//it will cause buffer overflows
char food[5];
printf("Enter favorite food: ");
fgets(food, sizeof(food), stdin);
printf("your favorite food is :%s\n",food);
*/
char *cards="JQK";
//string literals can never be updated
//the following code will cause one error,
//but it will pass compile
//why cause this? the string literals will store one read only memory.
//these constants will be used all threads, so can not changed.
//cards[1]='K';
puts(cards);
printf("address of the cards is :%p\n",cards);
printf("address of the string JQK is :%p\n",&"JQK");
char cards2[]="JQK";
puts(cards2);
printf("address of the cards is :%p\n",cards2);}
refer: head first C
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,088
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,564
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,412
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,185
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,822
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905