/*****************************P1*****************************/
#include <stdio.h>
/**just a simple hello word**/
int main(void)
{
printf("hello, word");
return 0;
}
/*****************************P2*****************************/
#include <stdio.h>
#include <stdlib.h>
/**just a simple function**/
int doubleNumber(int n){
return n+n;
}
/*****************************P3*****************************/
#include <stdio.h>
#include <stdlib.h>
int doubleNumber(int n);
int main(int argc,char* args[]){
if(argc<2){
printf("Please input one arg.");
return -1;
}
int number = atoi(args[1]);
printf("%d double result is %d",number,doubleNumber(number));
return 0;
}
/*****************************P3*****************************/
#include <stdio.h>
#include <stdlib.h>
/**Read File Content**/
int main(int argc,char* args[]){
if(argc<2){
printf("Please input the file name.\n");
return -1;
}
char* fileName=args[1];
FILE *fp;
char* line;
if(access(*fileName,0)){
printf("The file %s cannot be access.",fileName);
}
if((fp=fopen(fileName,"r"))==NULL){
printf("The file %s is not exists or can not be read.",fileName);
return -1;
}
while (!feof(fp)){
if(fgets(line,9999,fp)!=NULL){
printf("Read content:%s",line);
}
}
fclose(fp);
return 0;
}
/*****************************P4*****************************/
#include <stdio.h>
#include <stdlib.h>
/**Call Linux command**/
int main(int argc,char* args[]){
int result;
result=system("ls -l");
printf("the result call linux command is %d",result);
return 0;
}
/*****************************P5*****************************/
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/**Call Linux command by popen and get the result**/
int main(int argc,char* args[]){
int result;
FILE *stream;
char buf[1024];
memset(buf,'\n',sizeof(buf));
stream=popen("ls -l","r");
fread(buf,sizeof(char),sizeof(buf),stream);
printf("the result is:\n %s",buf);
pclose(stream);
return 0;
}
/*****************************P6*****************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/**Show time**/
int main(int argc,char* args[]){
while(1==1){
system("date");
sleep(1);
}
return 0;
}
/*****************************P7*****************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/**Show time in a new line, just append effect**/
int main(int argc,char* args[]){
while(1==1){
system("date");
printf("\033[1A"); //back to last line
printf("\033[K"); //clean this line
sleep(1);
}
return 0;
}
/*****************************P8*****************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/**Show time, but remove before time, just keep current time**/
int main(int argc,char* args[]){
FILE *stream;
char buf[1024];
memset(buf,'\0',sizeof(buf));
while(1==1){
stream=popen("date","r");
fread(buf,sizeof(char),sizeof(buf),stream);
pclose(stream);
printf("%s",buf);
printf("\033[1A"); //back to last line
printf("\033[K"); //clean this line
sleep(1);
}
return 0;
}
/*****************************P9*****************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/**Show time, but remove before time, just keep current time**/
int main(int argc,char* args[]){
FILE *stream;
char buf[1024];
memset(buf,'\0',sizeof(buf));
system("clear");
while(1==1){
stream=popen("date","r");
fread(buf,sizeof(char),sizeof(buf),stream);
pclose(stream);
printf("\033[1A"); //back to last line
printf("\033[K"); //clean this line
printf("%s",buf);
sleep(1);
}
return 0;
}
/*****************************P10*****************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/**Show multi dynamic lines in the screen, like the top command**/
int main(int argc,char* args[]){
FILE *stream;
char buf[1024];
int currentLine;
memset(buf,'\0',sizeof(buf));
//clear the screen
system("clear");
while(1==1){
//get current date
stream=popen("date","r");
fread(buf,sizeof(char),sizeof(buf),stream);
pclose(stream);
printf("\033[2A"); //back to last 2 line, see the usage:http://blog.youkuaiyun.com/xiaowall/article/details/8299985
currentLine=1;
while(currentLine<2){ //loop remove the line in the screen
printf("\033[K"); //clean current line
currentLine++;
}
printf("%s",buf);
printf("%s",buf);
sleep(1);
}
return 0;
}
相关推荐
PostgreSQL高可用之主备复制
多个PostgreSQL可协同工作,如果主库发生宕机备库将迅速进行接管并对外提供服务以实现高可用。本文将从主备复制、主备切换、故障转移等角度进行实际测试演练。第一章主备复制是基础,通过主备复制可以得到一个或多个相同的实例。在主备复制的基础上通过第二章主备切换介绍了如何手工将主库与备库互换角色。在第三章中,采用了Keepalived进行实时监测,在主库宕机后,使用主备切换中提到的命令使备库升级为主库并对外提供服务,以达到PostgreSQL高可用的目标。
Android上的C/C++语言开发工具--simpleC开源
介绍 simpleC是Android上的C/C++语言开发工具,可以编辑并编译C/C++代码,并支持代码高亮显示,头文件和常用函数自动补全,代码自动缩进,编辑器文本大小缩放,快速注释/取消注释代码,编辑时撤退等功能。 编译器使用gcc编译器,词法分析器采用JFlex。该文本编辑器采用自定义View来绘制文本,高效绘制,并且可以轻易改成其他语言使用的文本编辑器,不仅如此,想要将文本编辑器扩展成更强
一步一步教你写股票走势图——K线图一(概述)
股票分时图部分已经开发完毕,受到了广大开发者的好评!界面、功能都挺完美,解决了好一些MP开发者的问题,博主甚是欣悦,更有动力去开源K线图。这里说一下,如果有问题直接留言或者发邮件,github上个人信息有邮件,我看到基本都会回复,博主不加qq的,体谅O(∩_∩)O。分析好了,废话不多说,我们分析下K线图吧,首先我们看下自选股K线图的效果吧效果还是很赞的,经过分时图的研究后,博主越来越确信自选股用的应
探索 SimpleC:轻松学习 C 语言的在线编译器与教程平台
探索 SimpleC:轻松学习 C 语言的在线编译器与教程平台 去发现同类优质开源项目:https://gitcode.com/ 项目简介 是一个专为初学者设计的在线 C 语言学习和实践平台。它集成了编译器、代码编辑器和交互式教程,让用户无需安装任何软件即可开始编写 C 语言程序。通过这个平台,你可以快速地学习基础知识,即时查看代码执行结果,并逐步提升你的编程技能。 技术分析 SimpleC 的核...
SECS/GSM 测试工具 SecsExpress 的配置与实战应用
本文详细介绍了半导体设备通讯测试工具SecsExpress的配置与实战应用。作为专业的SECS/GSM协议调试工具,它能模拟Host与设备端进行双向测试,帮助工程师快速部署、验证通讯链路,并高效排查与RMS系统或真实设备间的联调问题,是提升半导体工厂设备集成与维护效率的利器。
基础矩阵、本质矩阵、单应矩阵
基础矩阵是一个 3×3 的秩为2的矩阵,用于描述两个不同视图(或称为图像)之间对应点的几何约束。更具体地说,如果你有两幅图像,分别从两个不同的相机或者相机位置拍摄,那么基础矩阵可以用于找到一个图像中的点在另一个图像中的对应点。本质矩阵也是一个 3×3 的秩为2的矩阵,与基础矩阵非常类似。当两个视图(图像)之间的场景是一个平面或者两个视图之间仅有旋转和平移时,可以使用单应矩阵来关联这两个视图。这三个矩阵都是在计算机视觉中广泛应用的基础工具,但它们适用于不同类型的视图和场景。给定两个图像中的一对对应点。
simple c语言,一个SimpleC语言解释器的实现 1语言定义和实现步骤简介
一个SimpleC语言解释器的实现 1语言定义和实现步骤简介一个SimpleC语言解释器的实现 1语言定义和实现步骤简介最近在学习编译原理的知识,从最初的感觉很神秘,到后来的豁然开朗,走了很多弯路,在这里做一个记录,希望能和大家交流,一起学习。我们这里实现的是一个简单的无类型的语言,我把它叫做SimpleC,语法格式与C语言基本一致,下面对其做一个简单的定义:SimpleC语言定义1.变量没有类...
基于 SoC 的卷积神经网络车牌识别系统设计(1)引言
通过 CPU 软核 IP 在纯 FPGA 平台上构建一个 AI SoC 卷积神经网络车牌识别系统,其中,缩放、填充层、卷积层、ReLU、池化层、全连接层 IP 都是 Verilog 设计的,同时集成了各种高性能的 IP。这是最具挑战性的 AI SoC 芯片设计项目,集成了 Python 卷积神经网络代码、Verilog 卷积神经网络硬件设计、ARM SoC 设计、ARM 与 FPGA 的交叉编译流程等等。这不仅是科研学习、集创竞赛、秋招求职的一个极具优势的精彩项目,也是目前最火热的芯片行业之中的一个...
A simple C program
停车场管理系统,无对应文档,需自创
Spring AI 项目实战(一):Spring AI 核心模块入门
摘要:本文探讨了Spring Boot与Spring AI在Java生态下开发智能应用的技术融合。Spring Boot通过自动配置和嵌入式服务器简化企业级应用开发,其核心架构包括Spring Application和Web MVC框架。Spring AI则提供标准化接口,整合Hugging Face、TensorFlow等AI引擎,模块化支持NLP、CV和ML任务。文章通过代码示例展示了文本分类、图像处理和机器学习预测的实现,为开发者提供了Java生态下高效构建AI应用的解决方案。
osgearth添加经纬度网格,并显示鼠标所指经纬高度信息
一、代码 osgearth官方例子 #include <osg/Notify> #include <osgGA/StateSetManipulator> #include <osgViewer/Viewer> #include <osgViewer/ViewerEventHandlers> #include <osgEarth/MapNode> #include <osgEarthUtil/EarthManipulator> #
How to Debug C Program using gdb in 6 Simple Steps
http://www.thegeekstuff.com/2010/03/debug-c-program-using-gdb/ Earlier we discussed the basics of how to write and compile a C program with C Hello World Program. In this article, let us dis
手把手教你学Simulink——基于Simulink的无位置传感器PMSM滑模观测器(SMO)控制
本文基于Simulink平台实现无位置传感器PMSM滑模观测器(SMO)控制,解决了传统机械位置传感器存在的成本高、体积大、抗干扰差等问题。SMO通过滑模切换函数估算反电动势,进而获得转子位置和速度,具有强鲁棒性(参数变化20%误差仅0.4°)和良好低速性能(50rpm转矩衰减<5%)。文章详细介绍了PMSM数学模型、SMO算法设计、Simulink建模步骤及参数优化方法,提供了可直接工程应用的MATLAB代码和仿真模型,为电动汽车驱动、工业机器人等高精度控制场景提供了有效解决方案。
Clion STM32 GNU Cmake报错 The C compiler is not able to compile a simple test program.解决
【代码】Clion STM32 GNU Cmake报错 The C compiler is not able to compile a simple test program.解决。
TMS_WebGMaps_1.9.8.0_Full_Source
TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder
大中型超市收银系统(可直接运行)
光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开
C++之父文章1:How do I write this very simple program?
Often, especially at the start of semesters, I get a lot of questions about how to write very simple programs. Typically, the problem to be solved is to read in a few numbers, do something with them
RU DOS版、EFI版32bit/64bit BIOS常用工具
DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。
A simple IOCP Server/Client Class
A simple IOCP Server/Client ClassBy spinoza. This source code uses the advanced IOCP technology which can efficiently serve multiple clients. It also presents some solutions to practical problems that arise with the IOCP programming API, and provides a sim
VC中sqlite的使用
在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示
计算机二级[英文]-C统计年龄段人树—东方仙盟
Use VC++2010 to open the solution in the candidate folder named prog1. The project contains one source file prog1.c. You need to write function in this program.The function requirement: Count the number of people in each age group. N ages are obtained by
hdu 1497 Simple Library Management System 【简单图书管理系统】
题目 After AC all the hardest problems in the world , the ACboy 8006 now has nothing to do . One day he goes to an old library to find a part-time job .It is also a big library which has N books and M users.The user’s id is from 1 to M , and the book id is
POJ - 3468 A Simple Problem with Integers 经典线段树问题
POJ - 3468 A Simple Problem with Integers You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a g...
深入解析 tonic-prost:ProstCodec 与 gRPC 消息编解码实现指南
`tonic-prost` 是 gRPC Rust 生态中负责"把 protobuf 消息序列化成 gRPC 线上字节流、以及从线上字节流反序列化回 protobuf 消息"的核心编解码层。本文以 [tonic-prost/README.md](https://link.gitcode.com/i/ff3869926e7c36bd27eb4eb50f2fe478) 为主体,结合仓库内 `tonic
C/C++ 一些知识点总结
临时整理的,有些可能不对。 1)如果一个类里面有const-qualifier或reference, compiler不会为它生成default copy assignment operator函数。 2) Hidden是指子类和父类有同名函数,但又没有virtual关键字。这里函数只要同名就可以了,参数并不需要match。也就是说,compiler只要在子类看到有这个函数名,即使参数不...
计算机二级[英文]-C字符串前面增加*—东方仙盟
Use VC++2010 to open the solution in the candidate folder named modi. The project contains one source file modi1.c. The function : insert asterisk characters at the beginning of the string to form a new string, and overwrite the original string. The maxi
V 语言完整参考文档解析:从安装编译到 C 互操作的权威指南
`doc/docs.md` 是 V 语言仓库中唯一且最权威的语言参考文档(9363 行),同时充当语言规范、使用手册与高级主题指南。本文以该文档为骨架,结合仓库中的 [examples](https://link.gitcode.com/i/7d988895b7437429ab502d25b3e56a23)、[vlib/v](https://link.gitcode.com/i/60c1efb41
C语言返回函数指针精讲:从语法到回调与查表工程实践
函数指针是C语言中理解底层运行机制的关键概念,它本质上是存储函数入口地址的指针变量,通过它可以在运行时动态选择要执行的逻辑。而返回函数指针则进一步打破了函数只能返回数据的限制,允许一个函数根据条件返回另一个函数的地址,从而实现流程与业务的解耦。借助typedef定义函数指针类型,可以极大简化复杂声明的可读性,这也是工程中常见做法。在实际开发中,返回函数指针常用于回调机制、命令分发器、事件处理等场景,通过查表方式组织函数指针数组,能构建出高度可扩展的“面向接口”代码结构。理解其类型安全、作用域陷阱以及判空保护
第18章 分页:介绍
Simulation
nachos3.4 threads管理 (c++)
Main.cc //引导代码初始化操作系统内核。允许直接调用内部操作系统功能,简化调试和测试。在实践中,bootstrap代码只会初始化数据结构, //并启动一个用户程序来打印登录提示。//许多内容只有在分配之后才是需要的。(比如说在线程管理中,我们只定义了THREAD,这样文件系统等相关信息就不会被执行) // Usage: nachos -d <debugflags> -rs...
1347



被折叠的 条评论
为什么被折叠?



