小编Pra*_*bha的帖子

我不明白为什么答案是5,我会写下面的程序

#include<stdio.h>
void main()
{
 int cats,dogs,others,total_pets;
 cats=10;
 dogs=43;
 others=36;
 total_pets=cats+dogs;
 printf("there are %c  total pets are",total_pets);
}
Run Code Online (Sandbox Code Playgroud)

c

1
推荐指数
1
解决办法
165
查看次数

无法使用C读取文件

这是我的代码:

 #include<stdio.h>
 #include<stdlib.h>
void main()
{
 int n,i,a[40];
 char file_name[100];
 FILE *file;
 printf("enter the file name\n");
     scanf("%s",&file_name);
 printf("enter the size\n");
 scanf("%d",&n);

 if((file=fopen(file_name,"rb"))==NULL)
 {
  printf("cant open a file\n");
  return;
 }
 fread(a,sizeof(int),n,file);
 for(i=0;i<n;i++)
 {
  printf("%s",a[i]);
 }
}
Run Code Online (Sandbox Code Playgroud)

c

-1
推荐指数
1
解决办法
180
查看次数

在这种情况下理解预处理器指令?

#define swap(a,b,c)(int t;t=a;a=b;b=t;);
void main()
{
    int x=10,y=20;
    swap (x,y,int);
    printf("%d %d\n",x,y);
}
Run Code Online (Sandbox Code Playgroud)

什么是输出,为什么?

c macros c-preprocessor

-3
推荐指数
1
解决办法
590
查看次数

标签 统计

c ×3

c-preprocessor ×1

macros ×1