代码拉取完成,页面将自动刷新
同步操作将从 guohuacai/learnC2 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int trimstr(char* dst,char *src)
{
char* from = src;
char* to = dst;
if (dst == NULL || src == NULL)
{
return -1;
}
int begin = 0;
int end = strlen(from) - 1;
while (from[begin]==' '&& from[begin]!=0)
{
begin++;
}
while (from[end] == ' '&& from[end] != 0)
{
end--;
}
int count = end - begin + 1;
src = src + begin;
strncpy(dst, src, count);
dst[count] = '\0';
return 0;
}
int trimstr2(char* dst, char *src)
{
char* from = src;
char* to = dst;
int i = 0;
int j = 0;
if (dst == NULL || src == NULL)
{
return -1;
}
int begin = 0;
int end = strlen(from) - 1;
while (from[begin] == ' '&& from[begin] != 0)
{
begin++;
}
while (from[end] == ' '&& from[end] != 0)
{
end--;
}
int count = end - begin + 1;
printf("src=%s", src);
for ( i = 0,j=begin; i < count,j<=end; i++,j++)
{
dst[i] = src[j];
}
dst[count] = '\0';
return 0;
}
char * trim2ends(char* src){
char *dst = (char*)malloc(100);
int count = 0;
if (src != NULL)
{
char * from = src;
int begin = 0;
int end = strlen(from) - 1;
while (from[begin] == ' '&& from[begin] != 0)
{
begin++;
}
while (from[end] == ' '&& from[end] != 0)
{
end--;
}
count = end - begin + 1;
src = src + begin;
strncpy(dst, src, count);
}
dst[count] = 0;
return dst;
}
int main(int argc, char const *argv[])
{
char* p = " i love sexy girls ";
//char dst[100];
char *result;
//trimstr2(dst,p);
result = trim2ends(p);
printf("result=%s\n", result);
system("pause");
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。