嵌入式基础应用开发之Linux开发环境搭建及初步指令(苏嵌日志之Monday)

环境资料下载:
1.VMware workstation 12虚拟机下载链接:
https://pan.baidu.com/s/1HC7OeUF1ZZLQwQawR3EQkg 密码:nt9d
2.Linux 安装镜像下载
(Red Hat5.11)
链接:https://pan.baidu.com/s/164TsEZ0hh4xPxM6-PAtEoQ 密码:55ff

编程环境安装
1.VMware workstation 12安装
这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

2.Linux(Red Hat)
具体安装参考https://blog.csdn.net/yert_alan/article/details/79182532

学习日志
姓名:沈壮壮
1.课堂回顾
C语言复习要点
–内存以字节为单位,一个字节一个地址。
–各数据类型所占的字节数:Char 1,int 4,short 2,long 4,double 8
–指针是存储数据地址的类型 ,(*p)++对数值有影响,对地址无影响。其它有关的括号无影响
–strcpy拷贝字符
–a[5] 其a++,首地址加1字节地址;&a+1 数组地址加1数组字节地址
–野指针(系统随机,不可用)Ptr =(char *) malloc(4); //分配地址解决
Free(ptr)//释放,不使用,内存泄漏
–空指针的概念
–结构体struct

    #include <stdio.h>
    int main(){
        printf("Hello, World!\n");
        return 0;
     }

输入完成,按”ESC”键,回到一般模式,然后按下shift+z 后z保存即可保存并退出vim。
编译和运行:gcc [options] [filenames]

[root@localhost c]# ls
hello.c
[root@localhost c]# gcc hello.c
[root@localhost c]# ls
a.out  hello.c

执行:

[root@localhost c]# ./a.out
Hello, World!

使用-o编译选择,可以为编译后的文件指定一个名字:

[root@localhost c]# ls
a.out  hello.c
[root@localhost c]# gcc hello.c -o hello
[root@localhost c]# ls
a.out  hello  hello.c

执行:

[root@localhost c]# ./hello
Hello, World!

其它Linux基本操作:
cd usr 切换到该目录下usr目录
cd ../ 切换到上一层目录
cd / 切换到系统根目录
cd ~ 切换到用户主目录
cd - 切换到上一个所在目录
mkdir 目录名称 增加目录操作
ls [-al] 父目录 查看目录
find 目录 参数 寻找目录
mv 目录 新目录 修改目录的名称
mv 目录 目录新位置 移动目录位置
rm [-rf] 目录 删除目录
2.待解决的问题
在帮同学win7系统下安装VMware workstation 12虚拟机时,出现这里写图片描述
错误。
对windows虚拟机的服务设置,和安装临时文件的操作(vc++2008),都未成功安装。建议重新安装操作系统(个人见解)。
3.自我评价
对于代码的熟练度不高,打字的速度过慢,陈旧知识过的遗忘,有待提高。
4.课后练习
题目3: 输入一个字符串,计算字符串中子串出现的次数

 #include<stdio.h>
 #include<string.h>
int fun(char *a, char *b)
{
    int len_b;
    int count = 0;
    int num = 0;
    char *temp = b;

    len_b = strlen(b);

    while (*a != '\0')
    {
        if (*a == *temp)
        {
            while ((*a == *temp) && (*a != '\0') && (*temp != '\0'))
            {
                num++;
                a++;
                temp++;
            }
            if (num == len_b)
            {
                count++;
            }
            num = 0;
            temp = b;
        }
        else
        {
            a++;
        }
    }

    return count;
}

int main()
{
    char a[100];
    char b[10];
    int num;

    printf("Enter the main string(<=100)!\n");
    scanf("%s",a);
    printf("Enter the substring(<=10)!\n");
    scanf("%s",b);
    num = fun(a,b);
    printf("The number is:%d\n",num);

    return 0;
}

题目4: 编写一个C函数,将”I am from shanghai ”倒置为”shanghai from am I”,即将句子中的单词位置倒置,而不改变单词内部结构.

 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

int main()
{
    char str[] = "I am from Shanghai";
    char *p1 = str;
    char *p2 = str+strlen(str)-1;
    char temp;
    char *p3 = NULL;
    while(p1<p2)
    {
        temp = *p1;
        *(p1++) = *p2;
        *(p2--) = temp;
    }
    puts(str);
    p1 = str;
    p2 = str;
    while(*p2)
    {
        if(*p2 == ' ')
        {
            p3 = p2 - 1;
            while(p1<p3)
            {
                temp = *p1;
                *(p1++) = *p3;
                *(p3--) = temp;
            }
            p1 = p2 + 1;
        }
        p2++;
    }

   p3 = p2-1;
    while(p1<p3)
    {
        temp = *p1;
        *(p1++) = *p3;
        *(p3--) = temp;
    }
printf("%s",str);
return 0;
} 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值