69,368
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
#include<stdlib.h>
int main()
{
char *p = NULL;
char *string1 = NULL;
int n = strlen(string1);
int i;
i = n;
printf("请输入一段字符:\n"); // 我加上的代码!
scanf("%s",string1); // 我加上的代码!
if(p == NULL)
{
p = (char *)malloc(n*sizeof(char *));
}
printf("%s\n",string1);
for(p = string1;*p!='\0';p++);
p--;//使p指向最后一个位置。
for(i;i>0;i--)
{
if(*p == '\\')
break;
p--;
}
n = i;
printf("出现的最后一个位置是%d\n",n);
if(p != NULL)
{
p = NULL;
free(p);
}
}
#include<stdio.h>
#include<stdlib.h>
int main()
{
char *p = NULL;
char *string1 = (char *)malloc(256); // 无初始化值!
int n = strlen(string1);
int i;
i = n;
printf("请输入一段字符:\n"); // 我加上的代码!
scanf("%s",string1); // 我加上的代码!
if(p == NULL)
{
p = (char *)malloc(n*sizeof(char *));
}
//printf("%s\n",string1);
for(p = string1;*p != '\0';p++);
p--;//使p指向最后一个位置。
for(i;i>0;i--)
{
if(*p == '\\')
break;
p--;
}
n = i;
printf("出现的最后一个位置是%d\n",n);
if(p != NULL)
{
p = NULL;
free(p);
}
system("pause");
return 0;
}