我正在尝试使用纯 JavaScript 连接到我的 firestore。(我现在想加快速度并跑步)
索引.js:
import app from './firebase.js'
import { getFirestore } from 'https://www.gstatic.com/firebasejs/9.0.0/firebase-firestore.js'
const db = getFirestore(app)
Run Code Online (Sandbox Code Playgroud)
但是,这会引发错误:Uncaught Error: Service firestore is not available
firebase.js:
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.0.1/firebase-app.js";
const firebaseConfig = {
// configs
};
// Initialize Firebase
let app
export default app = initializeApp(firebaseConfig);
Run Code Online (Sandbox Code Playgroud)
然后我将脚本导入到我的index.html
:
<!DOCTYPE html>
....
<script type="module" src="index.html"></script>
Run Code Online (Sandbox Code Playgroud)
注意:我可以使用 firebase Web 界面读取和写入 firestore。
我试图彻底理解一个陈述和一个表达之间的区别
但是我发现它甚至在阅读了这个答案之后就会感到困惑.
表达式和声明
请看下面的内容:
std::cout << "Hello there? " ;
Run Code Online (Sandbox Code Playgroud)
我可以说它是一个声明,因为它以分号结尾但我也可以说它
是一个表达式,因为我有一个ostream,一个输出运算符和一个字符串文字
,这个表达式产生的值是左手操作数.
哪一个是正确的?
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1,a,b,c,choice;
do
{
printf("enter any two numbers\n");
scanf("%d%d",&a,&b);
printf("pressing one add the two numbers\nenter one if you want to\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
{
c=a+b;
printf("the sum of the entered numbers%.1f\n\n:",c);
break;
}
default:
printf("you have entered an invalid");
break;
}
clrscr();
}
while(i==1);
getch();
}
Run Code Online (Sandbox Code Playgroud)
我不知道是因为我的同学使用的是turbo c,对我来说很好,我使用的是dev c ++,但看起来像clrscr(); 请编译器帮助未知。
我有这些代码
#include<stdio.h>
void main()
{
int a;
scanf("%d",&a);
printf("%d",(int)a);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,当我输入a作为输入时,我得到45作为ASCII等价物,现在我决定将这些代码更改为:
#include<stdio.h>
void main()
{
int a;
scanf("%c",&a);
printf("%d",(int)a);
}
Run Code Online (Sandbox Code Playgroud)
它显示了97的正确答案,我不明白%c的差异.
我有一个数据库参考.
houseReference = FirebaseDatabase.getInstance().getReference("House");
Run Code Online (Sandbox Code Playgroud)
我使用以下命令向db添加项:
houseReference.push().setValue(house);
Run Code Online (Sandbox Code Playgroud)
Google firebase参考文档说您可以获取最后一项使用的密钥
houseReference.getKey();
Run Code Online (Sandbox Code Playgroud)
但是,这会回来House
.我究竟做错了什么?
我有这个功能:
void fraction::init()
{
cout<<"enter the values for the numerator and denominator\n";
cin>>num;
cin>>denom;
}
Run Code Online (Sandbox Code Playgroud)
我希望这两个数字用于操纵它们的另一个函数.我该如何将它们带到其他功能?注意:两个功能属于同一类.
我有这个功能:
int second(int x,int c[100])
{
int b,e=0;
for(b=0;b<x;b++)
{
if(c[b]!=(65||117))
e++;
}
return (e);
}
Run Code Online (Sandbox Code Playgroud)
此循环将检查数组中有多少个数不等于
65或117,并且要递增的值用于计算这些
数字的数量,此值将返回到main函数.
现在我想在main函数中使用返回的值.这是我使用的语法:
h=second(x,c[100]);
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
"passing argument 2 of second makes pointer from integer without a cast"
Run Code Online (Sandbox Code Playgroud)
如何使函数返回该值?
我有这段代码片段
const int col= 5;const int row= 5;
int a[row][col] = {0};
int (*p)[col] ;
p = a;
Run Code Online (Sandbox Code Playgroud)
这些语句打印相同的地址
cout <<p;
cout << endl;
cout << *p;
Run Code Online (Sandbox Code Playgroud)
在我看来,因为p
指向一个5的数组ints
,解引它
应该给出第一个似乎不是这样的值.
救命!