zoukankan      html  css  js  c++  java
  • Linux C语言编程

    Linux C语言编程

    任务要求

    1. 基于Ubuntu或OpenEuler完成下面的任务(OpenEuler有加分)
    2. 选择教材第二章的一节进行编程基础练习(2.10,2.11,2.12,2.13,2.14任选一个)
    3. 建立自己的项目目录,包含自己学号信息(如20190100linkedlist),构建项目结构(src, include,bin, lib, docs, test...),然后把相应代码和文档放置到正确位置,用tree命令查看项目结构,提交截图(5分)
    4. 进行gcc相关练习(ESc, iso, -I等)提交相关截图(5分)
    5. 进行静态库,动态库制作和调用练习,提交相关截图(5分)
    6. 进行gdb相关练习,至少包含四种断点的设置,提交相关截图(10分)
    7. 编写makefile(5分)

    程序编写

    • 我选择树的遍历C程序的编程练习

    "insert.h"

        struct node *insert(struct node *node,int key);
    
    

    "newnode.h"

       #ifndef NEWNODE_H
    #define NEWNODE_h
    struct node{
    	int key;
    	struct node *left,*right;
    };
    struct node *new_node(int key);
    #endif
    
    

    "insert.c"

    #include "newnode.h"
    #include "insert.h"
    #include<stdio.h>
    struct node *insert(struct node *node,int key)
    {
    	if(node==NULL)
    		return new_node(key);
    	if(key<node->key)
    		node->left = insert(node->left,key);
    	else if(key>node->key)
    		node->right = insert(node->right,key);
    	return node;
    }
    

    "newnode.c"

    #include "newnode.h"
    #include<stdio.h>
    #include<stdlib.h>
    struct node *new_node(int key)
    {
    	struct node *point = (struct node*)malloc(sizeof(struct node));
    	point->key=key;
    	point->left=point->right=NULL;
    	return point;
    }
    
    

    "main.c"

    #include<stdio.h>
    #include "insert.h"
    #include "newnode.h"
    
    void output(struct node *root){
    	if(root!=NULL)
    	{
    	printf("%d ",root->key);
    	output(root->left);
    	output(root->right);
    	}
    }
    
    int main(){
    int nodeValue[7]={56,23,34,27,30,47,86};
    int i;
    struct node *root = NULL;
    root = insert(root,nodeValue[0]);
    for(i=1;i<7;i++)
    	insert(root,nodeValue[i]);
    struct node *tree=root;
    output(tree);
    return 0;
    }
    
    

    2.建立自己的项目目录,包含自己学号信息(如20190100linkedlist),构建项目结构(src, include,bin, lib, docs, test...)

    3.gcc相关练习

    4.静态库

    5.动态库

    6.gdb相关练习
    断点设置
    b 函数名 设置函数断点
    b 行数 设置行断点
    b 行数 if i==2 设置条件断点
    tb 函数 设置临时断点
    调试
    r 运行
    s 单步运行
    n 单步运行 跳过函数内断点

    6、编写makefile

  • 相关阅读:
    [转]关于WM_NCHITTEST消息
    微信小程序的年月日-年月日选择器基于picker的mode = multiSelector日期范围
    解决移动端浏览器 HTML 音频不能自动播放的三种方法
    小程序反编译
    CSS实现背景透明,文字不透明
    event.target 属性返回哪个 DOM 元素触发了事件。
    微信小程序去除button边框
    jQuery setInterval倒计时精确到毫秒
    获取openid [微信小程序]
    array_column() 函数[二维数组转为一维数组]
  • 原文地址:https://www.cnblogs.com/kevin-hw/p/15340261.html
Copyright © 2011-2022 走看看