找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5147|回复: 2
打印 上一主题 下一主题
收起左侧

关于KEIL的C语言的数组定义问题的请教

[复制链接]
跳转到指定楼层
楼主
ID:393193 发表于 2019-5-19 21:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
源程序正确运行,如下:
#include<reg51.h>
#include<stdio.h>
#define uchar unsigned char
#define uint unsigned int
uchar data a[32] _at_ 0x30;
uint i _at_ 0x55;
uint j _at_ 0x60;
uint t _at_ 0x65;
uchar data a[]={1,3,9,2,17,4,11,6,5,20,100,64,21,14,79,35,92,7,91,23,65,16,13,18,18,73,65,101,27,19,62,69};
void main()
{
        for(i=0;i<31;i++)
        {
                for(j=0;j<31-i;j++)
                {
                        if(a[j]>a[j+1])
                        t=a[j],a[j]=a[j+1],a[j+1]=t;
                }
        }
        while(1);
}

为什么把数组定义放到程序里面后,数组的起始地址变为0x08 ???
修改后的程序:
#include<reg51.h>
#include<stdio.h>
#define uchar unsigned char
#define uint unsigned int
uchar data a[32] _at_ 0x30;
uint i _at_ 0x55;
uint j _at_ 0x60;
uint t _at_ 0x65;

void main()
{
        uchar data a[]={1,3,9,2,17,4,11,6,5,20,100,64,21,14,79,35,92,7,91,23,65,16,13,18,18,73,65,101,27,19,62,69};
        for(i=0;i<31;i++)
        {
                for(j=0;j<31-i;j++)
                {
                        if(a[j]>a[j+1])
                        t=a[j],a[j]=a[j+1],a[j+1]=t;
                }
        }
        while(1);
}
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:123289 发表于 2019-5-20 08:01 | 只看该作者
在程序用到这个“组”时,程序必须认识这个组。了解这个就可以了。
回复

使用道具 举报

板凳
ID:393193 发表于 2019-5-21 21:17 | 只看该作者
yzwzfyz 发表于 2019-5-20 08:01
在程序用到这个“组”时,程序必须认识这个组。了解这个就可以了。

好的,理解了,谢谢!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表