#include<stdio.h>
#define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
int array[] = {23, 34, 12, 17, 204, 99, 16};
int main() {
int d;
for (d = -1; d <= (TOTAL_ELEMENTS - 2); d++)
printf("%d\n", array[d + 1]);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
为什么for循环不能运行一次?
码:
#define f(a,b) a##b
#define g(a) #a
#define h(a) g(a)
main()
{
printf("%s\n",h(f(1,2))); //[case 1]
printf("%s\n",g(f(1,2))); //[case 2]
}
Run Code Online (Sandbox Code Playgroud)
输出:
12
f(1, 2)
Run Code Online (Sandbox Code Playgroud)
为什么两种情况下的输出都不相同?
[我在这里理解了连接(a##b)和字符串转换(#a),但我不明白为什么输出在两种情况下都不同.]
使用create table tab2 as select * from tab1;,我能够复制数据,但不能复制主键约束:
SQL> desc tab1;
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NOT NULL NUMBER
NAME VARCHAR2(20)
SQL> select * from tab1;
ID NAME
---------- --------------------
1 A
SQL> create table tab2 as select * from tab1;
Table created.
SQL> desc tab2;
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NUMBER
NAME VARCHAR2(20)
SQL> select * from tab2;
ID NAME
---------- --------------------
1 A
SQL>
Run Code Online (Sandbox Code Playgroud)
如何复制具有所有约束的表格?
什么需要用Python而不是C/C++等编码?我知道它的优点等我想知道为什么确切地使Python 成为这个行业中人们的语言?
SQL Plus是否为其命令提供帮助页面?有没有办法从SQL Plus提示符访问帮助文本,如STARTUP的此文本?
我试过了
SQL> man startup
SP2-0734: unknown command beginning "man startu..." - rest of line ignored.
SQL> startup -help
SP2-0714: invalid combination of STARTUP options
SQL> startup --help
SP2-0714: invalid combination of STARTUP options
SQL>
Run Code Online (Sandbox Code Playgroud) #!/bin/sh
tar=$1
if [ -f $tar ]
then
tar xvf $tar
else
exit 1
fi
... <more code>
Run Code Online (Sandbox Code Playgroud)
我需要一个tar实际上成功发生的构造,否则中止脚本的执行.
tar文件提取可能不会通过,因为
tar命令有些问题$tarLinux实用程序是否有一些返回值?我该如何在这里使用它们?
如何区分两个不同表中的行数?
SQL> select count(*) from dual44;
COUNT(*)
----------
3
SQL> select count(*) from dual;
COUNT(*)
----------
1
SQL> (select count(*) from dual44)
2 minus
3 (select count(*) from dual)
4 ;
COUNT(*)
----------
3
SQL>
Run Code Online (Sandbox Code Playgroud)
我需要2结果.这两个表可能不一定具有相同的情绪.
下面的代码给我一个编译错误,但我不明白我做错了什么.对于提出这么愚蠢的问题很抱歉.
$ cat swapcstrings.cc
#include <iostream>
void swap(char*& c, char*& d) {
char* temp = c;
c = d;
d = temp;
}
int main() {
char c[] = "abcdef";
char d[] = "ghijkl";
std::cout << "[" << c << "," << d << "]\n";
swap(c, d);
std::cout << "[" << c << "," << d << "]\n";
}
$ g++ swapcstrings.cc
swapcstrings.cc: In function ‘int main()’:
swapcstrings.cc:13: error: invalid initialization of non-const reference of type ‘char*&’ from a temporary …Run Code Online (Sandbox Code Playgroud) 错误!
$ cat double.cc
#include<iostream>
int main() {
int i = 42;
double &r = i;
}
$ g++ double.cc
double.cc: In function ‘int main()’:
double.cc:5: error: invalid initialization of reference of type ‘double&’
from expression of type ‘int’
$
Run Code Online (Sandbox Code Playgroud)
作品!
$ cat double.cc
#include<iostream>
int main() {
int i = 42;
const double &r = i;
}
$ g++ double.cc
$
Run Code Online (Sandbox Code Playgroud)
为什么我们在第一种情况下得到错误?我知道这是讨论在这里,但我不知道我明白为什么这个不准,而int以const double&被允许?