1、没有加上字符串结尾标志 空字符‘\0‘;
2、#include<stdio.h>
int main(void)
{
char note[]="See you at snack bar: ";
char *ptr;
ptr=note;
puts(ptr);
puts(++ptr);
note[7]=‘\0‘;
puts(note);
puts(++ptr);
return 0;
}
3、#include<stdio.h>
#include<string.h>
int main(void)
{
char food[]="Yummy";
char*ptr;
ptr=food+strlen(food);
while(--ptr>=food)
puts(ptr);//指针后退一下,就多输出一个字符
return 0;
}
4、#include<stdio.h>
#include<string.h>
int main(void)
{
char goldwyn[40]="art of it all ";
char samuel[40]="I read p";
char*quote="the way through.";
strcat(goldwyn,quote);
strcat(samuel,goldwyn);
puts(samuel);
return 0;
}
#include<stdio.h>
#include<string.h>
#define MAX 100
char*string_in(char*ptr,char*str,int n);
int main(void)
{
char arr1[MAX],arr2[MAX];
char *char_string;
int n;
printf("Please enter two character string.\n");
gets(arr1);
n=strlen(arr1);
gets(arr2);
#include<stdio.h>
#include<string.h>
#define MAX 100
char string_in(char*ptr ,int n );
int main(void)
{
char arr1[MAX] ;
int n;
printf("Please enter character string.\n");
while(1)
{ gets(arr1);
#define MAX 100
char string_in(char*ptr ,char arr[] );
int main(void)
{
char arr1[MAX] ,arr2[MAX] ;
int n;
printf("Please enter character string.\n");
while(1)
{
gets(arr1);
void First_word_length(int n,char*ptr[]);
int string_in(char *ptr);
void Quit();
int main(void)
{
int i,j,num;
char arr[LINE][RANK];
char *string[LINE];
printf("Please enter charater string.\n");
for(i=0;i<LINE;i++)
{ gets(arr[i]) ;
string[i]=arr[i];
}
while(1)
{
printf("Please choice number:\n");
printf("1)输出字符串列表 2)按ASCII顺序输出字符
串\n");
printf("3)按长度递增输出 4)按字符串第一个单词长
度输出 5)退出\n");
scanf("%d",&num);
switch(num)
{ case 1:charater_string(LINE,string); break; case 2:alphabet_list(LINE,string); break;
case 3:string_length(LINE,string); break; case 4:First_word_length(LINE,string); break; case 5:Quit(); break; default:break;
}
}
return 0;
}
void charater_string( int n,char*ptr[ ])
{
int i=0;
for(i=0;i<n;i++)
puts(ptr[i]);
}
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define LINE 5
#define RANK 100
void charater_string(char*ptr[],int n);
void alphabet_list(char*str[],int n);
void string_length(char*ptr[],int n);
void First_word_length(char*arr[],int n);
int string_in(char*ptr);
void Quit();
int main(void)
{
int i,j,num;
char arr[LINE][RANK];
printf("Please enter charater string.\n");
for(i=0;i<LINE;i++)
{ for(j=0;j<RANK;j++) { arr[i][j]=getchar(); }
}
printf("Please choice number:\n");
printf("1)输出字符串列表 2)按ASCII顺序输出字符
串\n");
printf("3)按长度递增输出 4)按字符串第一个单词长
度输出 5)退出\n");
scanf("%d",&num);
switch(num)
{ case 1:charater_string(arr[LINE],LINE); break; case 2:alphabet_list(arr[LINE],LINE); break;
case 3:string_length(arr[LINE],LINE); break; case 4:First_word_length(arr[LINE],LINE); break; case 5:Quit(); break; default:break;
}
int main(void)
{
int i,j,num;
char arr[LINE][RANK];
printf("Please enter charater string.\n");
for(i=0;i<LINE;i++)
{ gets(arr[i]) ;
}
while(1)
{ printf("Please choice number:\n");
printf("1)输出字符串列表 2)按ASCII顺序输出字符
串\n");
printf("3)按长度递增输出 4)按字符串第一个单词长
度输出 5)退出\n");
scanf("%d",&num);
switch(num)
{ case 1:charater_string(LINE,arr); break;/* case 2:alphabet_list(LINE,arr); break;
case 3:string_length(LINE,arr); break;*/ case 4:First_word_length(LINE,arr); break; case 5:Quit(); break; default:break;
}
////**********************************///
11\
#include<stdio.h>
#include<ctype.h>
int main(void)
{
int count=0;
int words=0;
int Big_char=0;
int Small_char=0;
int n=0;
int num=0,i=0;
char arr[]="ANJDNjdcj,saefnhc,1248nsm,lsd.";
char *ptr;
ptr=arr;
while(*ptr)
{if(isupper(*ptr))
Small_char++;
if(*ptr==‘ ‘)
words++; if(isalpha(*ptr))
count++;