do{
float diameter;
scanf("%f",&diameter);
Printf("Please input diameter");
if(cheack1(diameter) == 0){
Printf("Please input a valid number greater than 0");
}else{
circle(&area, &perimeter, diameter);
}
int cheack = cheack1(diameter);
}while(cheack == 1);
Run Code Online (Sandbox Code Playgroud)
我的do-while循环有问题.如你所见,我已经宣布了
int cheack = cheack1(diameter); 在cheack1(diameter);cheacks如果我输入的是正确的,如果它是正确的返回1.
但我的错误是:
p7t5.c: In function ‘main’:
p7t5.c:87:11: error: ‘cheack’ undeclared (first use in this function)
似乎while(cheack == 1);是不记得cheackdo-while循环内部.
我正在尝试打印一个数组但是我没有得到所需的输出,在循环完成打印预定义数组后会出现奇怪的数字.
代码是:
#include <stdio.h>
int main(){
int intArray[11] = {1,2,8,12,-13,-15,20,99,32767,10,31};
int i=0;
for(i=0;i<sizeof(intArray);i++){
printf("%d\n",intArray[i]);
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
1
2
8
12
-13
-15
20
99
32767
10
31
11
1629976468
2674040
2665720
1627423265
1
2665616
-2147417856
1629976534
1629976468
2674040
0
1627423172
1629976532
0
1629110043
0
0
0
0
0
0
0
0
0
0
0
1629976538
0
1629956432
2674276
0
1627407935
Run Code Online (Sandbox Code Playgroud) 我知道这可能是一个简单的错误,但我仍然无法弄清楚错误.我正进入(状态
当我打印出整数时,指针地址而不是值.
#include<stdio.h>
int main(){
char s1[100];
int words,lines,chara = 0;
FILE * fp;
fp = fopen("fox.txt","r");
if(fp==NULL){
printf("Can't open file");
}
else{
while (fscanf(fp,"%s",s1) != EOF){
words++;
// printf("%s",s1);
}
}
printf("There are %d of words",words);
}
Run Code Online (Sandbox Code Playgroud)
fox.txt
The quick
brown fox
jumps over
the lazy
dog
Run Code Online (Sandbox Code Playgroud)
输出:
There are 2665625 of words
Run Code Online (Sandbox Code Playgroud) private int[] list = {1,2,3,4,5,6,7,8,9};
Run Code Online (Sandbox Code Playgroud)
我应该用什么代码从这个列表中随机获取但唯一的数字.请为我提供最简单的初学者方式.谢谢你的帮助.