C语言试题大全三
输出到file2.txt:
(逆序)
答案:
注意可增长数组的应用.
#include
#include
int main(void)
{
int MAX = 10;
int *a = (int *)malloc(MAX * sizeof(int));
int *b;
FILE *fp1;
FILE *fp2;
{
}
for(;--j >= 0;)
fprintf(fp2,"%d",a[j]);
fclose(fp1);
fclose(fp2);
fclose(fp2);
free(a);
return 0;
}
}
2. 分析下面的代码:
char *a = "hello";
char *b = "hello";
if(a= =b)
printf("YES");
else
printf("NO");
"hello"是一个常量字符串。位于静态存储区,它在程序生命期内恒定不变。如果编译器优化的话,会有可能a和b同时指向同一个hello的。则地址相同。如果编译器没有优化,那么就是两个不同的地址,则不同
char *a = "hello";
char *b = "hello";
if(a= =b)
printf("YES");
else
printf("NO");
"hello"是一个常量字符串。位于静态存储区,它在程序生命期内恒定不变。如果编译器优化的话,会有可能a和b同时指向同一个hello的。则地址相同。如果编译器没有优化,那么就是两个不同的地址,则不同
3. 两个字符串,s,t;把t字符串插入到s字符串的第i个位置前,s字符串有足够的空间存放t字符串
答案:
void insert(char *s, const char *t, int i)
{
void insert(char *s, const char *t, int i)
{
}
关键词:
C语言试题大
评论