69,373
社区成员
发帖
与我相关
我的任务
分享
#include "stdio.h"
#include "string.h"
#include "memory.h"
main()
{
int i=0,j=0,nLen;
char *p,*q,str[]="My time is limited.",words[100][20];
memset(words,'\0',sizeof(words));
p=str;
while (*p)
{
if (*p==' ' || *p=='!' || *p==',' || *p=='.' || *p=='?')
{
words[i++][j]='\0';
j=0;
}else
{
if (j==0 && (*p>='a' && *p<='z'))
{
words[i][j++]=*p - 32;
}else
{
words[i][j++]=*p;
}
}
p++;
}
p=words[0];
//就从这里下面这段 大家帮忙
while (*p)
{
printf("%s\n",p+i);
}
}
#include <stdio.h> // 标准库中的头文件建议用<>
#include <string.h>
//#include "memory.h"
main()
{
int i=0,j=0,nLen;
char *p,*q,str[]="My ti* me is! limi#ted.",words[100][20];
memset(words,'\0',sizeof(words));
p=str;
while (*p)
{
//if (*p==' ' || *p=='!' || *p==',' || *p=='.' || *p=='?')
if(!(isalpha(*p) || isdigit(*p))) // 不是字母也不是数字,则为一个单词的结束
{
if(j > 0) // 当前单词长度不为空
{
words[i++][j]='\0';
j=0;
}
}
else
{
if (j==0 && (*p >= 'a' && *p <= 'z'))
{
words[i][j++]=*p - 32; // 将单词首字母变成大写
}
else
{
words[i][j++]=*p;
}
}
p++;
}
//p=words[0];
////就从这里下面这段 大家帮忙
//while (*p)
//{
// printf("p: %x\t", p);
// printf("%s\n", p++);
//}
i = 0;
while (strlen(words[i]) > 0)
{
printf("%d: %s\n", i, words[i]);
i++;
}
}
while (*p++)
{
printf("%c\n",p);
}
while (*p++)
{
printf("%s\n",p+i);
}
#include <stdio.h> // 标准库中的头文件建议用<>
#include <string.h>
main()
{
char *t[20]; // 声明一个指针数组,长度为20
char (*t2)[20]; // 声明一个指针,该指针指向含20个元素的数组
printf("%d: %x, %x\n", sizeof(t), t, t+1);
printf("%d: %x, %x\n\n", sizeof(t2), t2, t2+1);
//return 0;
int i=0,j=0,nLen;
char *p,*q,str[]="My ti* me is! limi#ted.",words[100][20];
memset(words,'\0',sizeof(words));
p=str;
while (*p)
{
//if (*p==' ' || *p=='!' || *p==',' || *p=='.' || *p=='?')
if(!(isalpha(*p) || isdigit(*p))) // 不是字母也不是数字,则为一个单词的结束
{
if(j > 0) // 当前单词长度不为空
{
words[i++][j]='\0';
j=0;
}
}
else
{
if (j==0 && (*p >= 'a' && *p <= 'z'))
{
words[i][j++]=*p - 32; // 将单词首字母变成大写
}
else
{
words[i][j++]=*p;
}
}
p++;
}
// 法一:用p
p=words[0];
while (strlen(p) > 0) // 用p
{
printf("p: %x\t%s\n", p, p);
p += 20;
}
printf("\n");
// 法二:用p2
char (*p2)[20] = words;
while (strlen((const char*)p2) > 0) // 用p2
{
printf("p2: %x\t%s\n", p2, p2);
p2++;
}
printf("\n");
//法三:用words
i = -1;
while (strlen(words[++i]) > 0) // 用words
{
printf("wrods[%d]: %s\n", i, words[i]);
}
}