2.基本概念

c生成可执行文件的过程

首先通过源代码翻译成目标代码,各类目标代码、库等最终通过链接器捆绑在
一起从而生成可执行文件
在这里插入图片描述

执行

可执行文件载入内存中便开始执行,在大多数的机器中,程序运行时将使用一个运行时stack(堆栈),存储函数的局部变量和返回地址,静态(static)变量存储于静态内存中,在程序整个生命周期中存活。

注释

单行注释使用//
多行注释使用/**/

标识符

在这里插入图片描述

课后习题

2.7-4

#include "stdafx.h"
#include "stdlib.h"

int main()
{
	printf("%c %c %c %c\n", '\40','\100','\x40','\0123');

	system("pause");
    return 0;
}


2.8-1

main.cpp

#include "stdafx.h"
#include "function.h"
#include "stdlib.h"

int main()
{

	printf("10 of Result: %d %d\n", negate(10), increment(10));
	printf("0 of Result: %d %d\n", negate(0), increment(0));
	printf("-10 of Result: %d %d\n", negate(-10), increment(-10));

	system("pause");
    return 0;
}

increment.cpp

#include "stdafx.h"

int increment(int a)
{
	return a+1;
}

negate.cpp

#include "stdafx.h"

int negate(int a)
{
	return -a;
}

function.h

#pragma once
#ifndef test
#define test
int negate(int a);
int increment(int a);
#endif
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值