相关题目
下面程序的功能是将字符串a 的所有字符传送到字符串b中, 要求每传送三个字符后再存放一个空格, 例如字符串a为"abcdefg " , 则字符串b 为"abc def g" , 请选择填空。
# include
main ( )
{ int i ,k = 0 ;
char a[ 80],b [ 80 ], *p ;
p =a ;
gets ( p ) ;
while (*p )
{ for ( i = 1 ;( ); p + + , k + + , i ++) b[ k]=* p ;
if (i==4) { b [k]=' '; k + + ; }
b[k]='\0';
puts ( b ) ;
}
当运行以下程序时,从键盘输入Happy! (表示回车),则下面:程序的运行结果是________。
# include
# include
main()
{ char str[10],*p=str;
gets(p);
printf("%d\n",stre(p));
}
stre(char str[])
{ int num=0;
while(*(str num)!='\0') num++ ;
return(num);
}
下面程序的运行结果是( )。
# include
main ( )
{ static char a[]="language ",b[]="progratne" ;
char *p1,*p2 ; int k ;
p1= a ; p2= b ;
for ( k = 0 ; k <-7 ; k + + )
if ( *(p1+k)==*(p2+k)) printf ("%c",*(p1+k)) ;
}
下面程序的运行结果是( )。
# include
main ( )
{ int a = 28 , b ;
char s [10],*p ;
p =s ;
do { b = a % 16 ;
if ( b < 10 ) *p=b + 48 ;
else *p = b + 55 ;
p++;
a = a / 5 ;
} while ( a > 0 ) ;
*p =‘\ 0 ' ;
puts ( s ) ;
}
下面程序的运行结果是( )。
# include
void delch ( char *s )
{Int i , j ;
char *a ;
a =s;
for ( i = 0 , j = 0 ; a [ i ] ! = ' \ 0 ';i++ ;)
if ( a [i ]>= '0'&&a[i]<='9') { s[j]=a[i];j++ ; }
s[j]='\0';
}
main ( )
{char * item = "a34bc" ;
delch ( item ) ;
printf ( "\n%s" , item) ; }
下面程序的运行结果是( )。
# include
# include
main ( )
{char *s1 =“AbDeG " ;
char *s2 = " AbdEg " ;
s1+=2 ; s2 +=2 ;
printf ( “%d\n” , strcmp ( s1 , s2 ) ) ;
}
下面程序的运行结果是( )。
#include
#include
fun(char *s)
{char a[7];
s=a;
strcpy(a,"look") ;
}
main ( )
{char *p;
fun(p);
puts(p);
}
下面程序的运行结果是( )。
#include
#include
fun(char *w,int n)
(char t,*s1,*s2;
s1=w;s2=w+n-1;
while(s1
main ()
{char *p;
p="1234567”;
fun(p,strlen(p));
puts(p);
}
下面程序的运行结果是( )。
#include
main()
{char *p,s[]="ABCDEFG";
for(p=s;*p!='\0';)
{printf("%s\n",p);
p++;
if(*p!='\0') p++;
else break ;
}
}
下面程序的运行结果是( )。
#include
#include
main ( )
{char *p1,*p2,str[50]="abc";
p1="abc"; p2="abc";
strcpy(str+1,strcat(p1,p2));
printf("%s\n",str);}
