20230713

该程序定义了字符指针,通过动态内存分配在堆区创建空间,然后从用户输入接收字符串。利用函数`my_strlen`计算字符串长度,最后用`free_s`函数释放内存。程序包含了错误处理和打印提示信息。

一:定义字符指针,分别指向堆区空间,计算字符串的长度
       要求:
      1.定义函数实现堆区空间申请
      2.在主函数中实现输入字符串
      3.定义函数实现字符串长度  size_t  my_strlen(const char *s)
      4.定义函数释放堆区空间

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

char *free_s(char *p);
char *Shengq();
size_t  *Cdu(char *p1);

int main(int argc, const char *argv[])
{
	char *ps = Shengq();

	printf("请输入字符串:\n");
	scanf("%s",ps);


	int leng = 0;
	leng = Cdu(ps);
	printf("字符串长度为:%d\n",leng);


	ps = free_s(ps);


	return 0;
}


size_t *Cdu(char *p1)
{
	int len=0;
	for(int i=0;*(p1+i)!='\0';i++)
	{
		len = len + 1;
	}
	return len;
}

char *Shengq()
{
	int *p2 = (int *)malloc(sizeof(int)*100);
	if(p2 == NULL)
	{
		printf("空间申请失败!\n");
		exit(1);
	}
	else
	{
		printf("空间申请成功!\n");
	}
	return p2;
}



char *free_s(char *p)
{
	if(p == NULL)
	{
		return NULL;
		printf("p==NULL,无需free释放。");
	}
	free(p);
	p = NULL;
	printf("释放完毕!");
	return p;

}

 

2.Minxd 

 

C:\Program Files\RabbitMQ Server\rabbitmq_server-3.7.4\sbin>rabbitmq-plugins enable rabbitmq_management Enabling plugins on node rabbit@WCQ-20230713FUA: rabbitmq_management The following plugins have been configured: rabbitmq_management rabbitmq_management_agent rabbitmq_web_dispatch Applying plugin configuration to rabbit@WCQ-20230713FUA... The following plugins have been enabled: rabbitmq_management rabbitmq_management_agent rabbitmq_web_dispatch set 3 plugins. Offline change; changes will take effect at broker restart. C:\Program Files\RabbitMQ Server\rabbitmq_server-3.7.4\sbin>rabbitmqctl status Status of node rabbit@WCQ-20230713FUA ... Error: unable to perform an operation on node 'rabbit@WCQ-20230713FUA'. Please see diagnostics information and suggestions below. Most common reasons for this are: * Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues) * CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server) * Target node is not running In addition to the diagnostics info below: * See the CLI, clustering and networking guides on http://rabbitmq.com/documentation.html to learn more * Consult server logs on node rabbit@WCQ-20230713FUA DIAGNOSTICS =========== attempted to contact: ['rabbit@WCQ-20230713FUA'] rabbit@WCQ-20230713FUA: * connected to epmd (port 4369) on WCQ-20230713FUA * epmd reports node 'rabbit' uses port 25672 for inter-node and CLI tool traffic * TCP connection succeeded but Erlang distribution failed * Authentication failed (rejected by the remote node), please check the Erlang cookie Current node details: * node name: 'rabbitmqcli58@WCQ-20230713FUA' * effective user's home directory: C:\Users\Administrator * Erlang cookie hash: ZczNPozL6A4JvfiBKogOfA==
08-14
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值