Learning c section 1

#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
时间: 2024-10-12 14:00:46

Learning c section 1的相关文章

(转)Understanding, generalisation, and transfer learning in deep neural networks

Understanding, generalisation, and transfer learning in deep neural networks FEBRUARY 27, 2017 This is the first in a series of posts looking at the 'top 100 awesome deep learning papers.' Deviating from the normal one-paper-per-day format, I'll take

Support Vector Machines for classification

Support Vector Machines for classification To whet your appetite for support vector machines, here’s a quote from machine learning researcher Andrew Ng: “SVMs are among the best (and many believe are indeed the best) ‘off-the-shelf’ supervised learni

OpenCV支持向量机(SVM)介绍

支持向量机(SVM)介绍 目标 本文档尝试解答如下问题: 如何使用OpenCV函数 CvSVM::train 训练一个SVM分类器, 以及用 CvSVM::predict 测试训练结果. 什么是支持向量机(SVM)? 支持向量机 (SVM) 是一个类分类器,正式的定义是一个能够将不同类样本在样本空间分隔的超平面. 换句话说,给定一些标记(label)好的训练样本 (监督式学习), SVM算法输出一个最优化的分隔超平面. 如何来界定一个超平面是不是最优的呢? 考虑如下问题: 假设给定一些分属于两类

[DOM Event Learning] Section 2 概念梳理 什么是事件 DOM Event

[DOM Event Learning] Section 2 概念梳理 什么是事件 DOM Event 事件 事件(Event)是用来通知代码,一些有趣的事情发生了. 每一个Event都会被一个Event对象所表示,这个对象可能还会有一些自定义的字段或者方法,来获取发生什么事情的更多信息. Event对象实现了Event接口(https://developer.mozilla.org/en-US/docs/Web/API/Event). 事件可以是任何事情,从最基本的用户交互,到renderin

[DOM Event Learning] Section 1 DOM Event 处理器绑定的几种方法

[DOM Event Learning] Section 1 DOM Event处理器绑定的几种方法 网页中经常需要处理各种事件,通常的做法是绑定listener对事件进行监听,当事件发生后进行一些特定处理. 监听事件的几种方法如下文. 第一种,写在页面标签里面 <button onclick="alert('Hello')">Say hello</button> 上面这行代码,将按钮点击后的弹窗操作在标签声明的时候就绑定了. 这是一种糟糕的方法,原因如下: 1

[DOM Event Learning] Section 4 事件分发和DOM事件流

[DOM Event Learning] Section 4 事件分发和DOM事件流 事件分发机制: event dispatch mechanism. 事件流(event flow)描述了事件对象在数据结构中是如何传播的. 传播路径 事件对象(event objects)被分发给事件目标(event target),在分发开始的时候,在实现中必须先确定事件对象的传播路径. 这个传播路径必须是一个有序的list,其中包含了事件对象必须通过的事件目标. 对于DOM的实现来说,这个传播路径必须反映这

An introduction to machine learning with scikit-learn

转自 http://scikit-learn.org/stable/tutorial/basic/tutorial.html#machine-learning-the-problem-setting In general, a learning problem considers a set of n samples of data and then tries to predict properties of unknown data. If each sample is more than

(转)The 9 Deep Learning Papers You Need To Know About (Understanding CNNs Part 3)

Adit Deshpande CS Undergrad at UCLA ('19) Blog About The 9 Deep Learning Papers You Need To Know About (Understanding CNNs Part 3) Introduction Link to Part 1Link to Part 2 In this post, we’ll go into summarizing a lot of the new and important develo

A Full Hardware Guide to Deep Learning

A Full Hardware Guide to Deep Learning Deep Learning is very computationally intensive, so you will need a fast CPU with many cores, right? Or is it maybe wasteful to buy a fast CPU? One of the worst things you can do when building a deep learning sy