当前位置:首页 > 代码 > 正文

无线点餐系统源代码c(基于单片机的无线点餐系统)

admin 发布:2022-12-19 22:11 144


今天给各位分享无线点餐系统源代码c的知识,其中也会对基于单片机的无线点餐系统进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

C语言编写点菜系统

简单的点菜系统,可供学习:

#include stdio.h

#include stdlib.h

#include errno.h

#include string.h

#include netdb.h

#include sys/types.h

#include netinet/in.h

#include sys/socket.h

#define SERVPORT 3333

#define MAXDATASIZE 100 /*每次最大数据传输量 */

int main(int argc, char *argv[])

{

int sockfd, recvbytes;

char buf[MAXDATASIZE];

struct hostent *host;

struct sockaddr_in serv_addr;

if (argc 2)

{ fprintf(stderr,"Please enter the server's hostname!\

"); exit(1); }

if ((host=gethostbyname(argv[1]))==NULL)

{ perror("gethostbyname出错!"); exit(1); }

if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)

{ perror("socket创建出错!"); exit(1); }

//初始化客户端

serv_addr.sin_family=AF_INET;

serv_addr.sin_port=htons(SERVPORT);

serv_addr.sin_addr = *((struct in_addr *)host-h_addr);

bzero((serv_addr.sin_zero),8);

//connect

if (connect(sockfd, (struct sockaddr *)serv_addr, sizeof(struct sockaddr)) == -1)

{ perror("connect error!"); exit(1); }

//recv

if ((recvbytes=recv(sockfd, buf, MAXDATASIZE, 0)) ==-1)

{ perror("recv出错!"); exit(1); }

buf[recvbytes] = '\\0';

printf("Received: %s",buf);

close(sockfd);

return 0;

}

客户端#include stdio.h

#include stdlib.h

#include errno.h

#include string.h

#include sys/types.h

#include netinet/in.h

#include sys/socket.h

#include sys/wait.h

#define SERVPORT 3333 /*服务器监听端口号 */

#define BACKLOG 10 /* 最大同时连接请求数 */

int main()

{

int sockfd,client_fd,sin_size; /*sock_fd:监听socket;client_fd:数据传输socket */

struct sockaddr_in my_addr; /* 本机地址信息 */

struct sockaddr_in remote_addr; /* 客户端地址信息 */

//创建一个套接字,PF_INET,流式,

if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)

{ perror("socket"); exit(1); }

//初始化服务端

my_addr.sin_family=AF_INET;

my_addr.sin_port=htons(SERVPORT);

my_addr.sin_addr.s_addr = INADDR_ANY;

bzero((my_addr.sin_zero),8);

//将套接字地址与所创建的套接字号联系起来

if (bind(sockfd, (struct sockaddr *)my_addr, sizeof(struct sockaddr)) == -1)

{ perror("bind"); exit(1); }

//愿意接收连接

if (listen(sockfd, BACKLOG) == -1)

{ perror("listen"); exit(1); }

while(1)

{

sin_size = sizeof(struct sockaddr_in);

if ((client_fd = accept(sockfd, (struct sockaddr *)remote_addr, sin_size)) == -1)

{ perror("accept"); continue; }

printf("received a connection from %s\

", inet_ntoa(remote_addr.sin_addr));

if (!fork()) { /* 子进程代码段 */

if (send(client_fd, "Hello, you are connected!\

", 26, 0) == -1)

perror("send"); close(client_fd); exit(0); }

close(client_fd); }

return 0;

}

扫码点餐源码系统怎么开发?

扫码点餐系统一般是基于微信进行开发的。

下面就给你介绍一下,如何基于微信开发一套扫码点餐系统:

方式:

1、基于微信公众号搭建“微点餐”系统

2、开发一个点餐小程序。

流程:

1、登录微信公众平台,申请、注册一个微信公众号或微信小程序

2、找一家像我们这样的,专业的开发公司,帮你在公众号上搭建一个“微点餐”系统或开发一个点餐小程序。

3、将开发好的系统或小程序,上传到公众平台审核

4、审核通过后,登录小程序管理后台,上传相关物料、设置一下就可以实现点餐了。

扫码点餐系统源码怎么开发?

1、登陆微信公众平台,申请、注册一个微信小程序

2、去找一家像我们这样的,专业的微信小程序开发服务商,帮你开发一个带有点餐功能的微信小程序。

3、等小程序开发出来之后,上传至平台审核

4、审核通过后,进入后台,设置一下,就可以实现扫码点餐了。

c语言点菜系统

// 下面是前期的点餐系统的基础数据维护,其它功能你可以自己尝试写,如果遇到什么问题可以提出来追问喔,相信你可以解决的(我怕代码太多提交会受字数限制)。

// mm.h 头文件

#includestdio.h

#includestdlib.h

#define MENU_NUM_MAX 100  // 假设有100种菜式

#define LEN sizeof(struct MenuInfo)

struct MenuInfo 

{

int ID;

char MenuName[20];

float price;

}Menu[MENU_NUM_MAX];

/*   基础数据维护 */

void AddMenu()

{

FILE *fp;

int menu_num;

printf("\t\t 你要添加多少种菜?:");

scanf("%d",menu_num);

for(int i=0;imenu_num;i++)

{

printf("\n"); // added this line

        printf("\t\t请输入ID:");

scanf("%d",Menu[i].ID);

printf("\t\t请输入菜名:");

scanf("%s",Menu[i].MenuName);

printf("\t\t请输入[%s]菜的价格:",Menu[i].MenuName);

Menu[i].price=0.0f; //initial float price

scanf("%f",Menu[i].price);

fflush(stdin);

}

if((fp=fopen("MenuInfo.dat","ab"))==NULL) // open binary file 

{

printf("Can't open file\n");

exit(1);

}

for(int j=0;jmenu_num;j++)

{   

if(fwrite(Menu[j],LEN,1,fp)!=1) //writing data to binary file

printf("Error writing file.\n");

}

   fclose(fp); // close file point

}

void DisplayMenuInfo()

{

    FILE *fp;

printf("\n\t\tID  菜名\t\t价格\n"); // column headings

    if((fp=fopen("MenuInfo.dat","rb"))==NULL) // open binary file 

{

printf("Can't open file\n");

exit(1);

}

int i=0;

do

{

        fseek(fp,i*LEN,SEEK_SET); // move file head location

if(fread(Menu[i],LEN,1,fp)) // read data save to structure variable

{

printf("\t\t%d  %5s\t\t%5.1f元\n",Menu[i].ID,Menu[i].MenuName,Menu[i].price);

i++;

}

}while(!feof(fp));

fclose(fp);

}

void DeleteToMenu()

{

FILE *fp; 

int MenuID;

int todelete=-1;

int i=0;

printf("请输入要删除的菜名的ID:");

scanf("%d",MenuID);

/* load or reload the file and check that record with that ID exists */

if((fp=fopen("MenuInfo.dat","rb"))==NULL) // open binary file 

{

printf("Can't open file\n");

exit(1);

}

do

{

fseek(fp,i*LEN,SEEK_SET); // move file head location

if(fread(Menu[i],LEN,1,fp))

{

if (Menu[i].ID==MenuID) todelete=i;   

i++;

}

}while(!feof(fp));

fclose(fp);

if (todelete==-1)

{

printf("A menu with that ID doesn't exist\n");

}

else

{

/* write records back to file excluding one to be deleted */

if((fp=fopen("MenuInfo.dat","wb"))==NULL) // open binary file 

{

printf("Can't open file\n");

exit(1);

}

for(int j=0;ji;j++)

if (j==todelete) continue;  /* skip record to be deleted */ 

if(fwrite(Menu[j],LEN,1,fp)!=1) //writing data to binary file

printf("Error writing file.\n");

}

fclose(fp); // close file point

}

}

void FindMenu()

{

FILE *fp;

int MenuID;

bool find_mark=false;

printf("\n\t\t请输入你要查找的菜名ID:");

scanf("%d",MenuID);

    

printf("\n\t\tID  菜名\t\t价格\n"); // column headings

if((fp=fopen("MenuInfo.dat","rb"))==NULL) // open binary file 

{

printf("Can't open file\n");

exit(1);

}

    int i=0;

do

{

        fseek(fp,i*LEN,SEEK_SET); // move file head location

fread(Menu[i],LEN,1,fp);  // read data save to structure variable

if(Menu[i].ID==MenuID)

{

printf("\t\t%d  %5s\t\t%5.1f元\n",Menu[i].ID,Menu[i].MenuName,Menu[i].price);

find_mark=true;

break;

}

i++;

}while(!feof(fp));

if(!find_mark) printf("\n\t 尊敬的客户:我们餐厅没有你要点的菜喔,你可以试试我们的招牌菜啊^-^.\n");

fclose(fp);

}

/*   基础数据维护完毕   */

// sc.cpp主文件

#include stdio.h

#include stdlib.h

#include "mm.h"

void main(void)

{

//AddMenu();

//DisplayMenuInfo();

//FindMenu();

}

C语言实习,餐厅点菜系统程序代码!

#includestdio.h

#includestdlib.h

#define ROW1 2

#define COL1 2

#define ROW2 COL1

#define COL2 4

int main(void)

{

int arr1[ROW1][COL1]=

{

{1,2},

{3,4}

},

arr2[ROW2][COL2]=

{

{1,2,1,2},

{1,2,1,2}

},

arr3[ROW2][COL2],i,j,k;

for(i=0;iROW1;i++)

{

for(j=0;jCOL2;j++)

{

arr3[i][j]=0;

for(k=0;kROW2;k++)

{

arr3[i][j]+=arr1[i][k]*arr2[k][j];

}

}

}

for(i=0;iROW2;i++)

{

for(j=0;jCOL2;j++)

{

printf("%-3d",arr3[i][j]);

}

printf("\n");

}

system("pause");

return(0);

}

无线点餐系统源代码c的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于基于单片机的无线点餐系统、无线点餐系统源代码c的信息别忘了在本站进行查找喔。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/26908.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载